From 170c3624e3e1b38e435b72be723b7207ed4b4069 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 27 Aug 2016 11:39:08 +0200 Subject: [PATCH] Use 'default' for move constructors refs #12555 --- lib/base/array.cpp | 2 +- lib/base/string.hpp | 16 ++++------------ lib/base/value-operators.cpp | 6 ------ lib/base/value.hpp | 12 ++++-------- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/lib/base/array.cpp b/lib/base/array.cpp index 581284aa9..916b49795 100644 --- a/lib/base/array.cpp +++ b/lib/base/array.cpp @@ -90,7 +90,7 @@ void Array::Add(Value&& value) { ObjectLock olock(this); - m_Data.push_back(value); + m_Data.push_back(std::move(value)); } /** diff --git a/lib/base/string.hpp b/lib/base/string.hpp index 38d94974c..159fbdc1b 100644 --- a/lib/base/string.hpp +++ b/lib/base/string.hpp @@ -77,13 +77,8 @@ public: : m_Data(n, c) { } - inline String(const String& other) - : m_Data(other.m_Data) - { } - - inline String(String&& other) - : m_Data(other) - { } + String(const String& other) = default; + String(String&& other) = default; inline ~String(void) { } @@ -93,11 +88,8 @@ public: : m_Data(begin, end) { } - inline String& operator=(const String& rhs) - { - m_Data = rhs.m_Data; - return *this; - } + String& operator=(const String& rhs) = default; + String& operator=(String&& rhs) = default; inline String& operator=(const std::string& rhs) { diff --git a/lib/base/value-operators.cpp b/lib/base/value-operators.cpp index 432b1603c..7adcbe207 100644 --- a/lib/base/value-operators.cpp +++ b/lib/base/value-operators.cpp @@ -94,12 +94,6 @@ std::istream& icinga::operator>>(std::istream& stream, Value& value) return stream; } -Value& Value::operator=(const Value& other) -{ - m_Value = other.m_Value; - return *this; -} - bool Value::operator==(bool rhs) const { return *this == Value(rhs); diff --git a/lib/base/value.hpp b/lib/base/value.hpp index 1d265a5af..68a2250cd 100644 --- a/lib/base/value.hpp +++ b/lib/base/value.hpp @@ -99,13 +99,8 @@ public: : m_Value(String(value)) { } - inline Value(const Value& other) - : m_Value(other.m_Value) - { } - - inline Value(Value&& other) - : m_Value(other.m_Value) - { } + Value(const Value& other) = default; + Value(Value&& other) = default; inline Value(Object *value) { @@ -129,7 +124,8 @@ public: operator double(void) const; operator String(void) const; - Value& operator=(const Value& other); + Value& operator=(const Value& other) = default; + Value& operator=(Value&& other) = default; bool operator==(bool rhs) const; bool operator!=(bool rhs) const; -- 2.40.0