forked from bblanchon/ArduinoJson
Fixed variant.is<nullptr_t>()
This commit is contained in:
@ -13,6 +13,7 @@ HEAD
|
|||||||
(ArduinoJson now produces standard UTF-8 instead of CESU-8)
|
(ArduinoJson now produces standard UTF-8 instead of CESU-8)
|
||||||
* Added `measureJson`, `measureJsonPretty`, and `measureMsgPack` to `keywords.txt`
|
* Added `measureJson`, `measureJsonPretty`, and `measureMsgPack` to `keywords.txt`
|
||||||
(This file is used for syntax highlighting in the Arduino IDE)
|
(This file is used for syntax highlighting in the Arduino IDE)
|
||||||
|
* Fixed `variant.is<nullptr_t>()`
|
||||||
|
|
||||||
> ### BREAKING CHANGES
|
> ### BREAKING CHANGES
|
||||||
>
|
>
|
||||||
|
@ -26,6 +26,14 @@ TEST_CASE("nullptr") {
|
|||||||
|
|
||||||
REQUIRE(variant.isNull());
|
REQUIRE(variant.isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("JsonVariant.is<nullptr_t>()") {
|
||||||
|
variant.set(42);
|
||||||
|
REQUIRE(variant.is<std::nullptr_t>() == false);
|
||||||
|
|
||||||
|
variant.clear();
|
||||||
|
REQUIRE(variant.is<std::nullptr_t>() == true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Issue #1120") {
|
TEST_CASE("Issue #1120") {
|
||||||
|
@ -91,6 +91,16 @@ class VariantRefBase {
|
|||||||
is() const {
|
is() const {
|
||||||
return variantIsObject(_data);
|
return variantIsObject(_data);
|
||||||
}
|
}
|
||||||
|
#if ARDUINOJSON_HAS_NULLPTR
|
||||||
|
//
|
||||||
|
// bool is<nullptr_t> const;
|
||||||
|
template <typename T>
|
||||||
|
FORCE_INLINE
|
||||||
|
typename enable_if<is_same<T, decltype(nullptr)>::value, bool>::type
|
||||||
|
is() const {
|
||||||
|
return variantIsNull(_data);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
FORCE_INLINE bool isNull() const {
|
FORCE_INLINE bool isNull() const {
|
||||||
return variantIsNull(_data);
|
return variantIsNull(_data);
|
||||||
|
Reference in New Issue
Block a user