Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55285 - sandbox/fmhess/boost/generic_ptr
From: fmhess_at_[hidden]
Date: 2009-07-30 14:45:19


Author: fmhess
Date: 2009-07-30 11:05:29 EDT (Thu, 30 Jul 2009)
New Revision: 55285
URL: http://svn.boost.org/trac/boost/changeset/55285

Log:
Tweaked how new_clone is used by default, so it can be usefully
overloaded for specific generic pointer types.

Text files modified:
   sandbox/fmhess/boost/generic_ptr/cloning.hpp | 17 +++++++++++++++--
   1 files changed, 15 insertions(+), 2 deletions(-)

Modified: sandbox/fmhess/boost/generic_ptr/cloning.hpp
==============================================================================
--- sandbox/fmhess/boost/generic_ptr/cloning.hpp (original)
+++ sandbox/fmhess/boost/generic_ptr/cloning.hpp 2009-07-30 11:05:29 EDT (Thu, 30 Jul 2009)
@@ -29,6 +29,19 @@
 {
   namespace generic_ptr
   {
+ template<typename T>
+ T* new_clone(T *p)
+ {
+ if(p == 0) return 0;
+ using boost::new_clone;
+ return new_clone(*p);
+ }
+ template<typename GenericPointer>
+ GenericPointer new_clone(const GenericPointer &p, typename pointer_traits<GenericPointer>::value_type * = 0)
+ {
+ return GenericPointer(new_clone(get_pointer(p)));
+ }
+
     namespace detail
     {
       class clone_factory_impl_base
@@ -53,7 +66,7 @@
         virtual clone_factory_impl* make_clone()
         {
           if(px == 0) return new clone_factory_impl(0);
- return new clone_factory_impl(new_clone(*px));
+ return new clone_factory_impl(new_clone(px));
         }
       private:
         T * px;
@@ -136,7 +149,7 @@
       GenericPointer operator()(const GenericPointer & p) const
       {
         if(get_plain_old_pointer(p) == 0) return p;
- return GenericPointer(new_clone(*p));
+ return new_clone(p);
       }
     };
 


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