diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-22 12:01:11 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-22 12:01:11 +0200 |
commit | cd09ab74e179fd4c42ad226fd5cc609485a8df01 (patch) | |
tree | 789858ff4ec3f2905fe71dc8f456f047c011ce82 | |
parent | b7bd0edb37e2941fbeeb26bd57c75eca82b765fb (diff) |
Add pointer kind and const_pointer to pointer traits
-rw-r--r-- | odb/pointer-traits.hxx | 14 | ||||
-rw-r--r-- | odb/tr1-pointer-traits.hxx | 7 |
2 files changed, 21 insertions, 0 deletions
diff --git a/odb/pointer-traits.hxx b/odb/pointer-traits.hxx index 34ec7cd..cd25820 100644 --- a/odb/pointer-traits.hxx +++ b/odb/pointer-traits.hxx @@ -14,6 +14,14 @@ namespace odb { + enum pointer_kind + { + pk_naked, // Naked or equivalent (i.e., unmanaged). + pk_unique, // Smart pointer that doesn't support sharing. + pk_shared, // Smart pointer that support sharing. + pk_weak // Weak counterpart for shared pointer. + }; + template <typename P> class pointer_traits; @@ -67,8 +75,11 @@ namespace odb class pointer_traits<T*> { public: + static pointer_kind const kind = pk_naked; + typedef T element_type; typedef T* pointer_type; + typedef const T* const_pointer_type; typedef naked_ptr_guard<pointer_type> guard_type; // Return naked pointer to the pointed-to element, including NULL. @@ -124,8 +135,11 @@ namespace odb class pointer_traits< std::auto_ptr<T> > { public: + static pointer_kind const kind = pk_unique; + typedef T element_type; typedef std::auto_ptr<element_type> pointer_type; + typedef std::auto_ptr<const element_type> const_pointer_type; typedef smart_ptr_guard<pointer_type> guard_type; static element_type* diff --git a/odb/tr1-pointer-traits.hxx b/odb/tr1-pointer-traits.hxx index edb5ce8..121a564 100644 --- a/odb/tr1-pointer-traits.hxx +++ b/odb/tr1-pointer-traits.hxx @@ -21,8 +21,11 @@ namespace odb class pointer_traits< std::tr1::shared_ptr<T> > { public: + static pointer_kind const kind = pk_shared; + typedef T element_type; typedef std::tr1::shared_ptr<element_type> pointer_type; + typedef std::tr1::shared_ptr<const element_type> const_pointer_type; typedef smart_ptr_guard<pointer_type> guard_type; static element_type* @@ -63,9 +66,13 @@ namespace odb class pointer_traits< std::tr1::weak_ptr<T> > { public: + static pointer_kind const kind = pk_weak; + typedef T element_type; typedef std::tr1::weak_ptr<element_type> pointer_type; + typedef std::tr1::weak_ptr<const element_type> const_pointer_type; typedef std::tr1::shared_ptr<element_type> strong_pointer_type; + typedef std::tr1::shared_ptr<const element_type> strong_const_pointer_type; }; } |