From 40466e02c3ab7ef31183158103e3ef7536248753 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 29 Feb 2012 10:57:43 +0200 Subject: Support for C++11 std::unique_ptr as object pointer This includes the odb::lazy_unique_ptr implementation. --- odb/lazy-pointer-traits.hxx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'odb/lazy-pointer-traits.hxx') 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 + class pointer_traits> + { + public: + static const pointer_kind kind = pk_unique; + static const bool lazy = true; + + typedef T element_type; + typedef lazy_unique_ptr pointer_type; + typedef std::unique_ptr eager_pointer_type; + + static bool + null_ptr (const pointer_type& p) + { + return !p; + } + + template + static typename object_traits::id_type + object_id (const pointer_type& p) + { + return p.object_id (); + } + }; + template - class pointer_traits > + class pointer_traits> { public: static const pointer_kind kind = pk_shared; @@ -90,7 +115,7 @@ namespace odb }; template - class pointer_traits > + class pointer_traits> { public: static const pointer_kind kind = pk_weak; -- cgit v1.1