@@ -54,7 +54,6 @@ int JSON_API msvc_pre1900_c99_snprintf(char* outBuf,
54
54
#define JSON_ASSERT_UNREACHABLE assert (false )
55
55
56
56
namespace Json {
57
-
58
57
template <typename T>
59
58
static std::unique_ptr<T> cloneUnique (const std::unique_ptr<T>& p) {
60
59
std::unique_ptr<T> r;
@@ -72,21 +71,22 @@ static std::unique_ptr<T> cloneUnique(const std::unique_ptr<T>& p) {
72
71
#else
73
72
#define ALIGNAS (byte_alignment )
74
73
#endif
75
- // static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
76
- // const unsigned char& kNullRef = kNull[0];
77
- // const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
78
- // const Value& Value::nullRef = null;
79
74
80
75
// static
81
76
Value const & Value::nullSingleton () {
82
77
static Value const nullStatic;
83
78
return nullStatic;
84
79
}
85
80
81
+ #if JSON_USE_NULLREF
86
82
// for backwards compatibility, we'll leave these global references around, but
87
83
// DO NOT use them in JSONCPP library code any more!
84
+ // static
88
85
Value const & Value::null = Value::nullSingleton ();
86
+
87
+ // static
89
88
Value const & Value::nullRef = Value::nullSingleton ();
89
+ #endif
90
90
91
91
const Int Value::minInt = Int (~(UInt (-1 ) / 2 ));
92
92
const Int Value::maxInt = Int (UInt (-1 ) / 2 );
@@ -1648,20 +1648,20 @@ const Value& Path::resolve(const Value& root) const {
1648
1648
for (const auto & arg : args_) {
1649
1649
if (arg.kind_ == PathArgument::kindIndex) {
1650
1650
if (!node->isArray () || !node->isValidIndex (arg.index_ )) {
1651
- // Error: unable to resolve path (array value expected at position...
1652
- return Value::null ;
1651
+ // Error: unable to resolve path (array value expected at position... )
1652
+ return Value::nullSingleton () ;
1653
1653
}
1654
1654
node = &((*node)[arg.index_ ]);
1655
1655
} else if (arg.kind_ == PathArgument::kindKey) {
1656
1656
if (!node->isObject ()) {
1657
1657
// Error: unable to resolve path (object value expected at position...)
1658
- return Value::null ;
1658
+ return Value::nullSingleton () ;
1659
1659
}
1660
1660
node = &((*node)[arg.key_ ]);
1661
1661
if (node == &Value::nullSingleton ()) {
1662
1662
// Error: unable to resolve path (object has no member named '' at
1663
1663
// position...)
1664
- return Value::null ;
1664
+ return Value::nullSingleton () ;
1665
1665
}
1666
1666
}
1667
1667
}
0 commit comments