From 8a9e1081c026a092c7dfb28fbd079b88850c7233 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Mar 2012 12:34:54 +0200 Subject: Portability workarounds for incomplete C++11 support in VC++ and old GCC --- odb/lazy-ptr.ixx | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'odb/lazy-ptr.ixx') diff --git a/odb/lazy-ptr.ixx b/odb/lazy-ptr.ixx index 5c67845..19150ef 100644 --- a/odb/lazy-ptr.ixx +++ b/odb/lazy-ptr.ixx @@ -480,9 +480,11 @@ namespace odb lazy_unique_ptr:: lazy_unique_ptr () {} +#ifdef ODB_CXX11_NULLPTR template lazy_unique_ptr:: lazy_unique_ptr (std::nullptr_t) {} +#endif template lazy_unique_ptr:: @@ -512,6 +514,7 @@ namespace odb lazy_unique_ptr:: lazy_unique_ptr (std::auto_ptr&& r): p_ (std::move (r)) {} +#ifdef ODB_CXX11_NULLPTR template lazy_unique_ptr& lazy_unique_ptr:: operator= (std::nullptr_t) @@ -519,6 +522,7 @@ namespace odb reset (); return *this; } +#endif template lazy_unique_ptr& lazy_unique_ptr:: @@ -560,12 +564,14 @@ namespace odb return p_.get (); } +#ifdef ODB_CXX11_EXPLICIT_CONVERSION_OPERATOR template lazy_unique_ptr:: operator bool() const { return p_ || i_; } +#endif template typename lazy_unique_ptr::pointer lazy_unique_ptr:: @@ -787,6 +793,15 @@ namespace odb return a.equal (b); } + template + inline bool + operator!= (const lazy_unique_ptr& a, + const lazy_unique_ptr& b) + { + return !a.equal (b); + } + +#ifdef ODB_CXX11_NULLPTR template inline bool operator== (const lazy_unique_ptr& a, std::nullptr_t) @@ -801,14 +816,6 @@ namespace odb return !b; } - template - inline bool - operator!= (const lazy_unique_ptr& a, - const lazy_unique_ptr& b) - { - return !a.equal (b); - } - template inline bool operator!= (const lazy_unique_ptr& a, std::nullptr_t) @@ -822,6 +829,7 @@ namespace odb { return b; } +#endif // // lazy_shared_ptr @@ -831,9 +839,11 @@ namespace odb inline lazy_shared_ptr:: lazy_shared_ptr () {} +#ifdef ODB_CXX11_NULLPTR template inline lazy_shared_ptr:: lazy_shared_ptr (std::nullptr_t) {} +#endif template template @@ -850,6 +860,7 @@ namespace odb inline lazy_shared_ptr:: lazy_shared_ptr (Y* p, D d, A a): p_ (p, d, a) {} +#ifdef ODB_CXX11_NULLPTR template template inline lazy_shared_ptr:: @@ -859,6 +870,7 @@ namespace odb template inline lazy_shared_ptr:: lazy_shared_ptr (std::nullptr_t p, D d, A a): p_ (p, d, a) {} +#endif template template @@ -1050,12 +1062,14 @@ namespace odb return p_.use_count (); } +#ifdef ODB_CXX11_EXPLICIT_CONVERSION_OPERATOR template inline lazy_shared_ptr:: operator bool () const { return p_ || i_; } +#endif template template @@ -1311,25 +1325,26 @@ namespace odb return a.equal (b); } - template + template inline bool - operator== (const lazy_shared_ptr& p, std::nullptr_t) + operator!= (const lazy_shared_ptr& a, const lazy_shared_ptr& b) { - return !p; + return !a.equal (b); } +#ifdef ODB_CXX11_NULLPTR template inline bool - operator== (std::nullptr_t, const lazy_shared_ptr& p) + operator== (const lazy_shared_ptr& p, std::nullptr_t) { return !p; } - template + template inline bool - operator!= (const lazy_shared_ptr& a, const lazy_shared_ptr& b) + operator== (std::nullptr_t, const lazy_shared_ptr& p) { - return !a.equal (b); + return !p; } template @@ -1345,6 +1360,7 @@ namespace odb { return p; } +#endif template inline void -- cgit v1.1