mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Fixed operator|(MemberProxy, JsonObject) (fixes #1415)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <ArduinoJson/Polyfills/attributes.hpp>
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
#include <ArduinoJson/Variant/VariantAs.hpp>
|
||||
#include <ArduinoJson/Variant/VariantTag.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
@@ -17,15 +18,24 @@ CompareResult compare(const T1 &lhs, const T2 &rhs); // VariantCompare.cpp
|
||||
|
||||
template <typename TVariant>
|
||||
struct VariantOperators {
|
||||
// Returns the default value if the VariantRef is undefined of incompatible
|
||||
// Returns the default value if the VariantRef is undefined or incompatible
|
||||
template <typename T>
|
||||
friend typename enable_if<!IsVisitable<T>::value, T>::type operator|(
|
||||
friend typename enable_if<!IsVariant<T>::value, T>::type operator|(
|
||||
const TVariant &variant, T defaultValue) {
|
||||
if (variant.template is<T>())
|
||||
return variant.template as<T>();
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
// Returns the default value if the VariantRef is undefined or incompatible
|
||||
template <typename T>
|
||||
friend typename enable_if<IsVariant<T>::value, typename T::variant_type>::type
|
||||
operator|(const TVariant &variant, T defaultValue) {
|
||||
if (variant)
|
||||
return variant;
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
// value == TVariant
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user