|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55311 - sandbox/fmhess/boost/generic_ptr
From: fmhess_at_[hidden]
Date: 2009-07-31 10:24:23
Author: fmhess
Date: 2009-07-31 10:24:23 EDT (Fri, 31 Jul 2009)
New Revision: 55311
URL: http://svn.boost.org/trac/boost/changeset/55311
Log:
Added generic_ptr::pointer_traits and rebind specializations for
some common smart pointers.
Text files modified:
sandbox/fmhess/boost/generic_ptr/pointer_traits.hpp | 60 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
Modified: sandbox/fmhess/boost/generic_ptr/pointer_traits.hpp
==============================================================================
--- sandbox/fmhess/boost/generic_ptr/pointer_traits.hpp (original)
+++ sandbox/fmhess/boost/generic_ptr/pointer_traits.hpp 2009-07-31 10:24:23 EDT (Fri, 31 Jul 2009)
@@ -21,8 +21,18 @@
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_pointer.hpp>
+namespace std
+{
+ template<typename T> class shared_ptr;
+ template<typename T> class unique_ptr;
+}
+
namespace boost
{
+ template<typename T> class shared_ptr;
+ template<typename T> class scoped_ptr;
+ template<typename T> class intrusive_ptr;
+
namespace generic_ptr
{
namespace detail
@@ -118,6 +128,56 @@
typedef ValueType * other;
};
+ // pointer traits for some external smart pointers
+ namespace detail
+ {
+ template<typename T> struct value_templated_ptr_pointer_traits
+ {
+ typedef T value_type;
+ typedef T * pointer;
+ typedef typename pointer_traits<T*>::reference reference;
+ };
+ } // namespace detail
+ template<typename T> struct pointer_traits<boost::shared_ptr<T> > :
+ public detail::value_templated_ptr_pointer_traits<T>
+ {};
+ template<typename T, typename ValueType>
+ struct rebind<boost::shared_ptr<T>, ValueType>
+ {
+ typedef boost::shared_ptr<ValueType> other;
+ };
+ template<typename T> struct pointer_traits<boost::scoped_ptr<T> > :
+ public detail::value_templated_ptr_pointer_traits<T>
+ {};
+ template<typename T, typename ValueType>
+ struct rebind<boost::scoped_ptr<T>, ValueType>
+ {
+ typedef boost::scoped_ptr<ValueType> other;
+ };
+ template<typename T> struct pointer_traits<boost::intrusive_ptr<T> > :
+ public detail::value_templated_ptr_pointer_traits<T>
+ {};
+ template<typename T, typename ValueType>
+ struct rebind<boost::intrusive_ptr<T>, ValueType>
+ {
+ typedef boost::intrusive_ptr<ValueType> other;
+ };
+ template<typename T> struct pointer_traits<std::shared_ptr<T> > :
+ public detail::value_templated_ptr_pointer_traits<T>
+ {};
+ template<typename T, typename ValueType>
+ struct rebind<std::shared_ptr<T>, ValueType>
+ {
+ typedef std::shared_ptr<ValueType> other;
+ };
+ template<typename T> struct pointer_traits<std::unique_ptr<T> > :
+ public detail::value_templated_ptr_pointer_traits<T>
+ {};
+ template<typename T, typename ValueType>
+ struct rebind<std::unique_ptr<T>, ValueType>
+ {
+ typedef std::unique_ptr<ValueType> other;
+ };
} // namespace generic_ptr
} // namespace boost
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk