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