Fix function returns incomplete class type on IAR (issue #2001)

Ported from 3e1be980d9
This commit is contained in:
Benoit Blanchon
2023-12-07 15:36:31 +01:00
parent 4cd03fbd26
commit 955815fbfa
2 changed files with 34 additions and 16 deletions

View File

@@ -56,9 +56,7 @@ class VariantRefBase : public VariantTag {
// https://arduinojson.org/v7/api/jsonvariant/as/
template <typename T>
FORCE_INLINE typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type
as() const {
return Converter<T>::fromJson(getVariant());
}
as() const;
template <typename T,
typename = typename enable_if<!is_same<T, TDerived>::value>::type>
@@ -88,9 +86,7 @@ class VariantRefBase : public VariantTag {
template <typename T>
FORCE_INLINE
typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type
is() const {
return Converter<T>::checkJson(getVariant());
}
is() const;
// Returns true if the value is of the specified type.
// https://arduinojson.org/v7/api/jsonvariant/is/
@@ -106,20 +102,12 @@ class VariantRefBase : public VariantTag {
// Copies the specified value.
// https://arduinojson.org/v7/api/jsonvariant/set/
template <typename T>
FORCE_INLINE bool set(const T& value) const {
Converter<T>::toJson(value, getOrCreateVariant());
auto resources = getResourceManager();
return resources && !resources->overflowed();
}
FORCE_INLINE bool set(const T& value) const;
// Copies the specified value.
// https://arduinojson.org/v7/api/jsonvariant/set/
template <typename T>
FORCE_INLINE bool set(T* value) const {
Converter<T*>::toJson(value, getOrCreateVariant());
auto resources = getResourceManager();
return resources && !resources->overflowed();
}
FORCE_INLINE bool set(T* value) const;
// Returns the size of the array or object.
// https://arduinojson.org/v7/api/jsonvariant/size/

View File

@@ -15,6 +15,13 @@ inline JsonVariant VariantRefBase<TDerived>::add() const {
return add<JsonVariant>();
}
template <typename TDerived>
template <typename T>
inline typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type
VariantRefBase<TDerived>::as() const {
return Converter<T>::fromJson(getVariant());
}
template <typename TDerived>
inline JsonArray VariantRefBase<TDerived>::createNestedArray() const {
return add<JsonArray>();
@@ -93,6 +100,13 @@ inline JsonVariant VariantRefBase<TDerived>::getOrCreateVariant() const {
return JsonVariant(getOrCreateData(), getResourceManager());
}
template <typename TDerived>
template <typename T>
inline typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type
VariantRefBase<TDerived>::is() const {
return Converter<T>::checkJson(getVariant());
}
template <typename TDerived>
inline ElementProxy<TDerived> VariantRefBase<TDerived>::operator[](
size_t index) const {
@@ -115,6 +129,22 @@ VariantRefBase<TDerived>::operator[](const TString& key) const {
return MemberProxy<TDerived, TString>(derived(), key);
}
template <typename TDerived>
template <typename T>
inline bool VariantRefBase<TDerived>::set(const T& value) const {
Converter<T>::toJson(value, getOrCreateVariant());
auto resources = getResourceManager();
return resources && !resources->overflowed();
}
template <typename TDerived>
template <typename T>
inline bool VariantRefBase<TDerived>::set(T* value) const {
Converter<T*>::toJson(value, getOrCreateVariant());
auto resources = getResourceManager();
return resources && !resources->overflowed();
}
template <typename TDerived>
template <typename T>
inline typename enable_if<is_same<T, JsonArray>::value, JsonArray>::type