forked from bblanchon/ArduinoJson
Make error message more readable in case of an invalid conversion
This commit is contained in:
@ -67,17 +67,16 @@ class JsonVariantConst : public detail::VariantTag,
|
|||||||
|
|
||||||
// Casts the value to the specified type.
|
// Casts the value to the specified type.
|
||||||
// https://arduinojson.org/v7/api/jsonvariantconst/as/
|
// https://arduinojson.org/v7/api/jsonvariantconst/as/
|
||||||
template <typename T>
|
template <typename T,
|
||||||
detail::enable_if_t<ConversionSupported<T>::value, T> as() const {
|
detail::enable_if_t<ConversionSupported<T>::value, bool> = true>
|
||||||
|
T as() const {
|
||||||
return Converter<T>::fromJson(*this);
|
return Converter<T>::fromJson(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casts the value to the specified type.
|
// Invalid conversion. Will not compile.
|
||||||
// https://arduinojson.org/v7/api/jsonvariantconst/as/
|
template <typename T,
|
||||||
template <typename T>
|
detail::enable_if_t<!ConversionSupported<T>::value, bool> = true>
|
||||||
detail::enable_if_t<!ConversionSupported<T>::value,
|
detail::InvalidConversion<JsonVariantConst, T> as() const;
|
||||||
detail::InvalidConversion<JsonVariantConst, T>>
|
|
||||||
as() const;
|
|
||||||
|
|
||||||
// Returns true if the value is of the specified type.
|
// Returns true if the value is of the specified type.
|
||||||
// https://arduinojson.org/v7/api/jsonvariantconst/is/
|
// https://arduinojson.org/v7/api/jsonvariantconst/is/
|
||||||
|
Reference in New Issue
Block a user