Skip to content

Commit 23c44d9

Browse files
committed
overload append function for R value references.
1 parent 8996c37 commit 23c44d9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/json/value.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,10 @@ Json::Value obj_value(Json::objectValue); // {}
447447
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
448448
Value& append(const Value& value);
449449

450+
#ifdef JSON_HAS_RVALUE_REFERENCES
451+
Value& append(Value&& value);
452+
#endif
453+
450454
/// Access an object value by name, create a null member if it does not exist.
451455
/// \note Because of our implementation, keys are limited to 2^30 -1 chars.
452456
/// Exceeding that will cause an exception.

src/lib_json/json_value.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,10 @@ Value const& Value::operator[](CppTL::ConstString const& key) const
11451145

11461146
Value& Value::append(const Value& value) { return (*this)[size()] = value; }
11471147

1148+
#ifdef JSON_HAS_RVALUE_REFERENCES
1149+
Value& Value::append(Value&& value) { return (*this)[size()] = value; }
1150+
#endif
1151+
11481152
Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
11491153
{
11501154
Value const* found = find(key, cend);

0 commit comments

Comments
 (0)