From 23c44d9f9eed8a7ff95daca9bd44526067c144c0 Mon Sep 17 00:00:00 2001 From: Dhruv Paranjape Date: Sat, 8 Jul 2017 17:30:47 +0530 Subject: [PATCH] overload append function for R value references. --- include/json/value.h | 4 ++++ src/lib_json/json_value.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/json/value.h b/include/json/value.h index 4aefb10..6b40831 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -447,6 +447,10 @@ Json::Value obj_value(Json::objectValue); // {} /// Equivalent to jsonvalue[jsonvalue.size()] = value; Value& append(const Value& value); +#ifdef JSON_HAS_RVALUE_REFERENCES + Value& append(Value&& value); +#endif + /// Access an object value by name, create a null member if it does not exist. /// \note Because of our implementation, keys are limited to 2^30 -1 chars. /// Exceeding that will cause an exception. diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 49b88f9..adae5a1 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -1145,6 +1145,10 @@ Value const& Value::operator[](CppTL::ConstString const& key) const Value& Value::append(const Value& value) { return (*this)[size()] = value; } +#ifdef JSON_HAS_RVALUE_REFERENCES + Value& Value::append(Value&& value) { return (*this)[size()] = value; } +#endif + Value Value::get(char const* key, char const* cend, Value const& defaultValue) const { Value const* found = find(key, cend);