mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-06-25 01:11:35 +02:00
Remove unnecessary universal references
This commit is contained in:
@ -19,10 +19,10 @@ class ArrayData : public CollectionData {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool addValue(T&& value, ResourceManager* resources);
|
||||
bool addValue(const T& value, ResourceManager* resources);
|
||||
|
||||
template <typename T>
|
||||
static bool addValue(ArrayData* array, T&& value,
|
||||
static bool addValue(ArrayData* array, const T& value,
|
||||
ResourceManager* resources) {
|
||||
if (!array)
|
||||
return false;
|
||||
|
@ -57,13 +57,13 @@ inline void ArrayData::removeElement(size_t index, ResourceManager* resources) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool ArrayData::addValue(T&& value, ResourceManager* resources) {
|
||||
inline bool ArrayData::addValue(const T& value, ResourceManager* resources) {
|
||||
ARDUINOJSON_ASSERT(resources != nullptr);
|
||||
auto slot = resources->allocVariant();
|
||||
if (!slot)
|
||||
return false;
|
||||
JsonVariant variant(slot.ptr(), resources);
|
||||
if (!variant.set(detail::forward<T>(value))) {
|
||||
if (!variant.set(value)) {
|
||||
resources->freeVariant(slot);
|
||||
return false;
|
||||
}
|
||||
|
@ -119,14 +119,13 @@ class VariantData {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool addValue(T&& value, ResourceManager* resources) {
|
||||
bool addValue(const T& value, ResourceManager* resources) {
|
||||
auto array = isNull() ? &toArray() : asArray();
|
||||
return detail::ArrayData::addValue(array, detail::forward<T>(value),
|
||||
resources);
|
||||
return detail::ArrayData::addValue(array, value, resources);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static bool addValue(VariantData* var, T&& value,
|
||||
static bool addValue(VariantData* var, const T& value,
|
||||
ResourceManager* resources) {
|
||||
if (!var)
|
||||
return false;
|
||||
|
@ -297,19 +297,18 @@ class VariantRefBase : public VariantTag {
|
||||
}
|
||||
|
||||
template <typename TConverter, typename T>
|
||||
bool doSet(T&& value) const {
|
||||
bool doSet(const T& value) const {
|
||||
return doSet<TConverter>(
|
||||
detail::forward<T>(value),
|
||||
is_same<typename function_traits<
|
||||
decltype(&TConverter::toJson)>::return_type,
|
||||
bool>{});
|
||||
value, is_same<typename function_traits<
|
||||
decltype(&TConverter::toJson)>::return_type,
|
||||
bool>{});
|
||||
}
|
||||
|
||||
template <typename TConverter, typename T>
|
||||
bool doSet(T&& value, false_type) const;
|
||||
bool doSet(const T& value, false_type) const;
|
||||
|
||||
template <typename TConverter, typename T>
|
||||
bool doSet(T&& value, true_type) const;
|
||||
bool doSet(const T& value, true_type) const;
|
||||
|
||||
ArduinoJson::JsonVariant getOrCreateVariant() const;
|
||||
};
|
||||
|
@ -140,7 +140,7 @@ VariantRefBase<TDerived>::operator[](const TString& key) const {
|
||||
|
||||
template <typename TDerived>
|
||||
template <typename TConverter, typename T>
|
||||
inline bool VariantRefBase<TDerived>::doSet(T&& value, false_type) const {
|
||||
inline bool VariantRefBase<TDerived>::doSet(const T& value, false_type) const {
|
||||
TConverter::toJson(value, getOrCreateVariant());
|
||||
auto resources = getResourceManager();
|
||||
return resources && !resources->overflowed();
|
||||
@ -148,7 +148,7 @@ inline bool VariantRefBase<TDerived>::doSet(T&& value, false_type) const {
|
||||
|
||||
template <typename TDerived>
|
||||
template <typename TConverter, typename T>
|
||||
inline bool VariantRefBase<TDerived>::doSet(T&& value, true_type) const {
|
||||
inline bool VariantRefBase<TDerived>::doSet(const T& value, true_type) const {
|
||||
return TConverter::toJson(value, getOrCreateVariant());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user