Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55319 - in sandbox/fmhess: boost/generic_ptr libs/generic_ptr/test
From: fmhess_at_[hidden]
Date: 2009-07-31 15:32:09


Author: fmhess
Date: 2009-07-31 15:32:09 EDT (Fri, 31 Jul 2009)
New Revision: 55319
URL: http://svn.boost.org/trac/boost/changeset/55319

Log:
Added overloads of cloning::reset for the custom deleter and
cloner cases. Fixed construction of cloning pointer from
pointer to const.

Text files modified:
   sandbox/fmhess/boost/generic_ptr/cloning.hpp | 18 ++++++++++++++++--
   sandbox/fmhess/libs/generic_ptr/test/cloning_test.cpp | 6 +++++-
   2 files changed, 21 insertions(+), 3 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-31 15:32:09 EDT (Fri, 31 Jul 2009)
@@ -23,6 +23,7 @@
 #include <boost/noncopyable.hpp>
 #include <boost/ptr_container/clone_allocator.hpp>
 #include <boost/scoped_ptr.hpp>
+#include <boost/type_traits/remove_const.hpp>
 #include <boost/utility/swap.hpp>
 
 namespace boost
@@ -69,8 +70,13 @@
         }
         virtual typename rebind<GenericPointer, void>::other get_pointer()
         {
- //FIXME: remove const from px's value_type
- return px;
+ return const_pointer_cast
+ <
+ typename remove_const
+ <
+ typename pointer_traits<GenericPointer>::value_type
+ >::type
+ >(px);
         }
         virtual clone_factory_pdc_impl* make_clone()
         {
@@ -338,6 +344,14 @@
       {
         cloning(p).swap(*this);
       }
+ template<typename U, typename D> void reset(U p, D d)
+ {
+ cloning(p, d).swap(*this);
+ }
+ template<typename U, typename D, typename C> void reset(U p, D d, C c)
+ {
+ cloning(p, d, c).swap(*this);
+ }
 
       pointer get() const {return px;}
 

Modified: sandbox/fmhess/libs/generic_ptr/test/cloning_test.cpp
==============================================================================
--- sandbox/fmhess/libs/generic_ptr/test/cloning_test.cpp (original)
+++ sandbox/fmhess/libs/generic_ptr/test/cloning_test.cpp 2009-07-31 15:32:09 EDT (Fri, 31 Jul 2009)
@@ -48,12 +48,16 @@
   boost::generic_ptr::cloning<X*> cp2(cp);
   BOOST_TEST(X::instances == 2);
   BOOST_TEST(cp != cp2);
- boost::generic_ptr::cloning<X*> cp3;
+ boost::generic_ptr::cloning<const X*> cp3;
   BOOST_TEST(X::instances == 2);
   cp3 = cp2;
   BOOST_TEST(X::instances == 3);
   BOOST_TEST(cp3->num_instances() == X::instances);
   BOOST_TEST(cp2 != cp3);
+
+ const X* p_to_const = new X();
+ cp3.reset(p_to_const);
+ BOOST_TEST(X::instances == 3);
 }
 
 void move_test()


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