aboutsummaryrefslogtreecommitdiff
path: root/butl
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-03-11 11:23:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-03-11 11:23:48 +0200
commitd1bd79770900f3b873f60d7559b97d2fb149eaf9 (patch)
tree67bd2937b6d2a0e54cf1580c3aa2e904596a2cc2 /butl
parenta9844a31c639ed5e0c8efee92d644557b8410429 (diff)
Add move constructor/assignment to optional
Diffstat (limited to 'butl')
-rw-r--r--butl/optional4
1 files changed, 4 insertions, 0 deletions
diff --git a/butl/optional b/butl/optional
index 00c204a..86bbe59 100644
--- a/butl/optional
+++ b/butl/optional
@@ -5,6 +5,8 @@
#ifndef BUTL_OPTIONAL
#define BUTL_OPTIONAL
+#include <utility> // move()
+
namespace butl
{
// Simple optional class template while waiting for std::optional.
@@ -21,9 +23,11 @@ namespace butl
optional (): null_ (true) {}
optional (nullopt_t): null_ (true) {}
optional (const T& v): value_ (v), null_ (false) {}
+ optional (T&& v): value_ (std::move (v)), null_ (false) {}
optional& operator= (nullopt_t) {value_ = T (); null_ = true; return *this;}
optional& operator= (const T& v) {value_ = v; null_ = false; return *this;}
+ optional& operator= (T&& v) {value_ = std::move (v); null_ = false; return *this;}
T& value () {return value_;}
const T& value () const {return value_;}