@@ -54,7 +54,6 @@ int JSON_API msvc_pre1900_c99_snprintf(char* outBuf,
5454#define JSON_ASSERT_UNREACHABLE assert (false )
5555
5656namespace Json {
57-
5857template <typename T>
5958static std::unique_ptr<T> cloneUnique (const std::unique_ptr<T>& p) {
6059 std::unique_ptr<T> r;
@@ -72,21 +71,22 @@ static std::unique_ptr<T> cloneUnique(const std::unique_ptr<T>& p) {
7271#else
7372#define ALIGNAS (byte_alignment )
7473#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;
7974
8075// static
8176Value const & Value::nullSingleton () {
8277 static Value const nullStatic;
8378 return nullStatic;
8479}
8580
81+ #if JSON_USE_NULLREF
8682// for backwards compatibility, we'll leave these global references around, but
8783// DO NOT use them in JSONCPP library code any more!
84+ // static
8885Value const & Value::null = Value::nullSingleton ();
86+
87+ // static
8988Value const & Value::nullRef = Value::nullSingleton ();
89+ #endif
9090
9191const Int Value::minInt = Int (~(UInt (-1 ) / 2 ));
9292const Int Value::maxInt = Int (UInt (-1 ) / 2 );
@@ -1648,20 +1648,20 @@ const Value& Path::resolve(const Value& root) const {
16481648 for (const auto & arg : args_) {
16491649 if (arg.kind_ == PathArgument::kindIndex) {
16501650 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 () ;
16531653 }
16541654 node = &((*node)[arg.index_ ]);
16551655 } else if (arg.kind_ == PathArgument::kindKey) {
16561656 if (!node->isObject ()) {
16571657 // Error: unable to resolve path (object value expected at position...)
1658- return Value::null ;
1658+ return Value::nullSingleton () ;
16591659 }
16601660 node = &((*node)[arg.key_ ]);
16611661 if (node == &Value::nullSingleton ()) {
16621662 // Error: unable to resolve path (object has no member named '' at
16631663 // position...)
1664- return Value::null ;
1664+ return Value::nullSingleton () ;
16651665 }
16661666 }
16671667 }
0 commit comments