Added a deprecation warning for is<char>() and is<char*>()

This commit is contained in:
Benoit Blanchon
2021-05-05 15:43:02 +02:00
parent 6aeefda3b6
commit c7c0b729c1
2 changed files with 78 additions and 2 deletions

View File

@ -123,10 +123,28 @@ class VariantRef : public VariantRefBase<VariantData>,
}
template <typename T>
FORCE_INLINE bool is() const {
FORCE_INLINE
typename enable_if<!is_same<T, char *>::value && !is_same<T, char>::value,
bool>::type
is() const {
return Converter<T>::checkJson(*this);
}
template <typename T>
FORCE_INLINE typename enable_if<is_same<T, char *>::value, bool>::type
ARDUINOJSON_DEPRECATED("Replace is<char*>() with is<const char*>()")
is() const {
return is<const char *>();
}
template <typename T>
FORCE_INLINE typename enable_if<is_same<T, char>::value, bool>::type
ARDUINOJSON_DEPRECATED(
"Support for char is deprecated, use int8_t or uint8_t instead")
is() const {
return is<signed char>();
}
template <typename T>
FORCE_INLINE operator T() const {
return as<T>();
@ -251,10 +269,28 @@ class VariantConstRef : public VariantRefBase<const VariantData>,
}
template <typename T>
FORCE_INLINE bool is() const {
FORCE_INLINE
typename enable_if<!is_same<T, char *>::value && !is_same<T, char>::value,
bool>::type
is() const {
return Converter<T>::checkJson(*this);
}
template <typename T>
FORCE_INLINE typename enable_if<is_same<T, char *>::value, bool>::type
ARDUINOJSON_DEPRECATED("Replace is<char*>() with is<const char*>()")
is() const {
return is<const char *>();
}
template <typename T>
FORCE_INLINE typename enable_if<is_same<T, char>::value, bool>::type
ARDUINOJSON_DEPRECATED(
"Support for char is deprecated, use int8_t or uint8_t instead")
is() const {
return is<signed char>();
}
template <typename T>
FORCE_INLINE operator T() const {
return as<T>();