From 644cba591ff6ec046ac4274b7c343dead847736e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 9 Nov 2015 18:14:37 +0200 Subject: Make database class move-constructible This means it can be returned by value from a function in C++11. --- odb/details/unique-ptr.hxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'odb/details') diff --git a/odb/details/unique-ptr.hxx b/odb/details/unique-ptr.hxx index 35f4d68..547dd3b 100644 --- a/odb/details/unique-ptr.hxx +++ b/odb/details/unique-ptr.hxx @@ -7,6 +7,8 @@ #include +#include + namespace odb { namespace details @@ -20,6 +22,20 @@ namespace odb explicit unique_ptr (T* p = 0): p_ (p) {} ~unique_ptr () {delete p_;} +#ifdef ODB_CXX11 + unique_ptr (unique_ptr&& p): p_ (p.p_) {p.p_ = 0;} + unique_ptr& operator= (unique_ptr&& p) + { + if (this != &p) + { + delete p_; + p_ = p.p_; + p.p_ = 0; + } + return *this; + } +#endif + private: unique_ptr (const unique_ptr&); unique_ptr& operator= (const unique_ptr&); -- cgit v1.1