From ec355c48c49074bebeb597f6e5dcedfeb9d52fae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Dec 2010 10:36:15 +0200 Subject: Add lazy pointer support Built-in support is provided for raw, auto, and tr1 shared/weak pointers. New test: common/lazy-ptr. --- odb/tr1-pointer-traits.hxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'odb/tr1-pointer-traits.hxx') diff --git a/odb/tr1-pointer-traits.hxx b/odb/tr1-pointer-traits.hxx index c21d46a..bbeceab 100644 --- a/odb/tr1-pointer-traits.hxx +++ b/odb/tr1-pointer-traits.hxx @@ -24,6 +24,7 @@ namespace odb { public: static pointer_kind const kind = pk_shared; + static bool const lazy = false; typedef T element_type; typedef std::tr1::shared_ptr pointer_type; @@ -45,7 +46,7 @@ namespace odb static bool null_ptr (const pointer_type& p) { - return p.get () == 0; + return !p; } public: @@ -69,12 +70,17 @@ namespace odb { public: static pointer_kind const kind = pk_weak; + static bool const lazy = false; typedef T element_type; typedef std::tr1::weak_ptr pointer_type; - typedef std::tr1::weak_ptr const_pointer_type; typedef std::tr1::shared_ptr strong_pointer_type; - typedef std::tr1::shared_ptr strong_const_pointer_type; + + static strong_pointer_type + lock (const pointer_type& p) + { + return p.lock (); + } }; } -- cgit v1.1