aboutsummaryrefslogtreecommitdiff
path: root/odb/lazy-ptr-impl.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-02-28 12:42:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-02-28 12:42:00 +0200
commiteaf07e23f93813fa2c2e6b4d67e69fc6f4c48673 (patch)
tree3b6a54db5d3019121b0bbd553322248ce45db4c2 /odb/lazy-ptr-impl.ixx
parent3012187847b2783c49153db3f5486b84074cb2b0 (diff)
Support for C++11 std::shared_ptr/weak_ptr as object pointers
This includes odb::lazy_shared_ptr and odb::lazy_weak_ptr implementations.
Diffstat (limited to 'odb/lazy-ptr-impl.ixx')
-rw-r--r--odb/lazy-ptr-impl.ixx62
1 files changed, 62 insertions, 0 deletions
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 <typename T>
+ inline lazy_ptr_impl<T>::
+ lazy_ptr_impl (lazy_ptr_impl&& r)
+ : lazy_ptr_base (std::move (r))
+ {
+ }
+
+ template <typename T>
+ template <typename Y>
+ inline lazy_ptr_impl<T>::
+ lazy_ptr_impl (lazy_ptr_impl<Y>&& r)
+ : lazy_ptr_base (std::move (r))
+ {
+ }
+
+ template <typename T>
+ inline lazy_ptr_impl<T>& lazy_ptr_impl<T>::
+ operator= (lazy_ptr_impl&& r)
+ {
+ lazy_ptr_base& b (*this);
+ b = std::move (r);
+ return *this;
+ }
+
+ template <typename T>
+ template <typename Y>
+ inline lazy_ptr_impl<T>& lazy_ptr_impl<T>::
+ operator= (lazy_ptr_impl<Y>&& r)
+ {
+ lazy_ptr_base& b (*this);
+ b = std::move (r);
+ return *this;
+ }
+#endif
+
template <typename T>
template <typename ID>
inline void lazy_ptr_impl<T>::