From eaf07e23f93813fa2c2e6b4d67e69fc6f4c48673 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 28 Feb 2012 12:42:00 +0200 Subject: Support for C++11 std::shared_ptr/weak_ptr as object pointers This includes odb::lazy_shared_ptr and odb::lazy_weak_ptr implementations. --- odb/lazy-ptr-impl.ixx | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'odb/lazy-ptr-impl.ixx') diff --git a/odb/lazy-ptr-impl.ixx b/odb/lazy-ptr-impl.ixx index ac11d59..cd49682 100644 --- a/odb/lazy-ptr-impl.ixx +++ b/odb/lazy-ptr-impl.ixx @@ -28,6 +28,32 @@ namespace odb { } +#ifdef ODB_CXX11 + inline lazy_ptr_base:: + lazy_ptr_base (lazy_ptr_base&& r) + : id_ (r.id_), db_ (r.db_), free_ (r.free_), copy_ (r.copy_) + { + r.id_ = 0; + } + + inline lazy_ptr_base& lazy_ptr_base:: + operator= (lazy_ptr_base&& r) + { + if (id_ != r.id_) + { + reset_id (); + id_ = r.id_; + db_ = r.db_; + free_ = r.free_; + copy_ = r.copy_; + + r.id_ = 0; + } + + return *this; + } +#endif + inline void lazy_ptr_base:: reset_id () { @@ -214,6 +240,42 @@ namespace odb return *this; } +#ifdef ODB_CXX11 + template + inline lazy_ptr_impl:: + lazy_ptr_impl (lazy_ptr_impl&& r) + : lazy_ptr_base (std::move (r)) + { + } + + template + template + inline lazy_ptr_impl:: + lazy_ptr_impl (lazy_ptr_impl&& r) + : lazy_ptr_base (std::move (r)) + { + } + + template + inline lazy_ptr_impl& lazy_ptr_impl:: + operator= (lazy_ptr_impl&& r) + { + lazy_ptr_base& b (*this); + b = std::move (r); + return *this; + } + + template + template + inline lazy_ptr_impl& lazy_ptr_impl:: + operator= (lazy_ptr_impl&& r) + { + lazy_ptr_base& b (*this); + b = std::move (r); + return *this; + } +#endif + template template inline void lazy_ptr_impl:: -- cgit v1.1