From fd4942b6f56227e9d90ad046ae011bc9db05eae0 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Tue, 7 Jul 2015 17:16:25 +0200 Subject: Make value copyable (after all) --- src/value.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/value.cpp b/src/value.cpp index d6c276471a..de173a94c2 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -32,6 +32,19 @@ value::value(tag&& t): tag_(std::move(t).move_clone()) {} +value::value(const value& rhs): + tag_(rhs.tag_ ? rhs.tag_->clone() : nullptr) +{} + +value& value::operator=(const value& rhs) +{ + if(this != &rhs) + { + tag_ = rhs.tag_ ? rhs.tag_->clone() : nullptr; + } + return *this; +} + value& value::operator=(tag&& t) { set(std::move(t)); @@ -356,11 +369,6 @@ value& value::operator[](const char* key) return (*this)[std::string(key)]; } -value value::copy() const -{ - return value(tag_->clone()); -} - std::unique_ptr& value::get_ptr() { return tag_; -- cgit 0.0.5-2-1-g0f52