aboutsummaryrefslogtreecommitdiff
path: root/odb/lazy-pointer-traits.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-02-29 10:57:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-02-29 10:57:43 +0200
commit40466e02c3ab7ef31183158103e3ef7536248753 (patch)
treedb4d542aae19b94e9be00636e9cf5b75c5c8cd7a /odb/lazy-pointer-traits.hxx
parent35a2460893ddfd006d9d85dcc6ab7a01c1ab9848 (diff)
Support for C++11 std::unique_ptr as object pointer
This includes the odb::lazy_unique_ptr implementation.
Diffstat (limited to 'odb/lazy-pointer-traits.hxx')
-rw-r--r--odb/lazy-pointer-traits.hxx29
1 files changed, 27 insertions, 2 deletions
diff --git a/odb/lazy-pointer-traits.hxx b/odb/lazy-pointer-traits.hxx
index 910e1e4..5273db1 100644
--- a/odb/lazy-pointer-traits.hxx
+++ b/odb/lazy-pointer-traits.hxx
@@ -64,8 +64,33 @@ namespace odb
};
#ifdef ODB_CXX11
+ template <typename T, typename D>
+ class pointer_traits<lazy_unique_ptr<T, D>>
+ {
+ public:
+ static const pointer_kind kind = pk_unique;
+ static const bool lazy = true;
+
+ typedef T element_type;
+ typedef lazy_unique_ptr<element_type, D> pointer_type;
+ typedef std::unique_ptr<element_type, D> eager_pointer_type;
+
+ static bool
+ null_ptr (const pointer_type& p)
+ {
+ return !p;
+ }
+
+ template <class O /* = T */>
+ static typename object_traits<O>::id_type
+ object_id (const pointer_type& p)
+ {
+ return p.object_id<O> ();
+ }
+ };
+
template <typename T>
- class pointer_traits<lazy_shared_ptr<T> >
+ class pointer_traits<lazy_shared_ptr<T>>
{
public:
static const pointer_kind kind = pk_shared;
@@ -90,7 +115,7 @@ namespace odb
};
template <typename T>
- class pointer_traits<lazy_weak_ptr<T> >
+ class pointer_traits<lazy_weak_ptr<T>>
{
public:
static const pointer_kind kind = pk_weak;