Boost logo

Boost-Commit :

From: pdimov_at_[hidden]
Date: 2008-05-03 15:29:02


Author: pdimov
Date: 2008-05-03 15:29:01 EDT (Sat, 03 May 2008)
New Revision: 45085
URL: http://svn.boost.org/trac/boost/changeset/45085

Log:
Fixes for MSVC 6.0.
Added:
   trunk/libs/smart_ptr/test/allocate_shared_test.cpp (contents, props changed)
Text files modified:
   trunk/boost/shared_ptr.hpp | 13 ++
   trunk/libs/smart_ptr/test/Jamfile.v2 | 1
   trunk/libs/smart_ptr/test/make_shared_test.cpp | 145 ----------------------------------------
   trunk/libs/smart_ptr/test/smart_ptr_test.cpp | 4 +
   trunk/libs/smart_ptr/test/sp_unary_addr_test.cpp | 5 +
   5 files changed, 20 insertions(+), 148 deletions(-)

Modified: trunk/boost/shared_ptr.hpp
==============================================================================
--- trunk/boost/shared_ptr.hpp (original)
+++ trunk/boost/shared_ptr.hpp 2008-05-03 15:29:01 EDT (Sat, 03 May 2008)
@@ -748,16 +748,23 @@
 
 } // namespace detail
 
-template<class D, class T> D * get_deleter(shared_ptr<T> const & p)
+template<class D, class T> D * get_deleter( shared_ptr<T> const & p )
 {
- D *del = detail::basic_get_deleter<D>(p.get_shared_count());
- if(del == 0)
+ D *del = detail::basic_get_deleter<D>( p.get_shared_count() );
+
+#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
+#else
+
+ if( del == 0 )
     {
         detail::sp_deleter_wrapper *del_wrapper = detail::basic_get_deleter<detail::sp_deleter_wrapper>(p.get_shared_count());
 // The following get_deleter method call is fully qualified because
 // older versions of gcc (2.95, 3.2.3) fail to compile it when written del_wrapper->get_deleter<D>()
         if(del_wrapper) del = del_wrapper->::boost::detail::sp_deleter_wrapper::get_deleter<D>();
     }
+
+#endif
+
     return del;
 }
 

Modified: trunk/libs/smart_ptr/test/Jamfile.v2
==============================================================================
--- trunk/libs/smart_ptr/test/Jamfile.v2 (original)
+++ trunk/libs/smart_ptr/test/Jamfile.v2 2008-05-03 15:29:01 EDT (Sat, 03 May 2008)
@@ -49,5 +49,6 @@
           [ run sp_convertible_test.cpp ]
           [ run wp_convertible_test.cpp ]
           [ run ip_convertible_test.cpp ]
+ [ run allocate_shared_test.cpp ]
         ;
 }

Added: trunk/libs/smart_ptr/test/allocate_shared_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/allocate_shared_test.cpp 2008-05-03 15:29:01 EDT (Sat, 03 May 2008)
@@ -0,0 +1,189 @@
+// allocate_shared_test.cpp
+//
+// Copyright (c) 2007, 2008 Peter Dimov
+//
+// Distributed under the Boost Software License, Version 1.0.
+// See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/make_shared.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+class X
+{
+private:
+
+ X( X const & );
+ X & operator=( X const & );
+
+public:
+
+ static int instances;
+
+ int v;
+
+ explicit X( int a1 = 0, int a2 = 0, int a3 = 0, int a4 = 0, int a5 = 0, int a6 = 0, int a7 = 0, int a8 = 0, int a9 = 0 ): v( a1+a2+a3+a4+a5+a6+a7+a8+a9 )
+ {
+ ++instances;
+ }
+
+ ~X()
+ {
+ --instances;
+ }
+};
+
+int X::instances = 0;
+
+int main()
+{
+ {
+ boost::shared_ptr< int > pi = boost::allocate_shared< int >( std::allocator<int>() );
+
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( *pi == 0 );
+ }
+
+ {
+ boost::shared_ptr< int > pi = boost::allocate_shared< int >( std::allocator<int>(), 5 );
+
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( *pi == 5 );
+ }
+
+ BOOST_TEST( X::instances == 0 );
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>() );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 0 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1+2 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1+2+3 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1+2+3+4 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1+2+3+4+5 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1+2+3+4+5+6 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1+2+3+4+5+6+7 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7, 8 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7, 8, 9 );
+ boost::weak_ptr<X> wp( pi );
+
+ BOOST_TEST( X::instances == 1 );
+ BOOST_TEST( pi.get() != 0 );
+ BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8+9 );
+
+ pi.reset();
+
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ return boost::report_errors();
+}

Modified: trunk/libs/smart_ptr/test/make_shared_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/make_shared_test.cpp (original)
+++ trunk/libs/smart_ptr/test/make_shared_test.cpp 2008-05-03 15:29:01 EDT (Sat, 03 May 2008)
@@ -47,26 +47,12 @@
     }
 
     {
- boost::shared_ptr< int > pi = boost::allocate_shared< int >( std::allocator<int>() );
-
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( *pi == 0 );
- }
-
- {
         boost::shared_ptr< int > pi = boost::make_shared< int >( 5 );
 
         BOOST_TEST( pi.get() != 0 );
         BOOST_TEST( *pi == 5 );
     }
 
- {
- boost::shared_ptr< int > pi = boost::allocate_shared< int >( std::allocator<int>(), 5 );
-
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( *pi == 5 );
- }
-
     BOOST_TEST( X::instances == 0 );
 
     {
@@ -82,20 +68,6 @@
         BOOST_TEST( X::instances == 0 );
     }
 
-
- {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>() );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 0 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
     {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1 );
         boost::weak_ptr<X> wp( pi );
@@ -110,19 +82,6 @@
     }
 
     {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
- {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1, 2 );
         boost::weak_ptr<X> wp( pi );
 
@@ -136,19 +95,6 @@
     }
 
     {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1+2 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
- {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1, 2, 3 );
         boost::weak_ptr<X> wp( pi );
 
@@ -162,19 +108,6 @@
     }
 
     {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1+2+3 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
- {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1, 2, 3, 4 );
         boost::weak_ptr<X> wp( pi );
 
@@ -188,19 +121,6 @@
     }
 
     {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1+2+3+4 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
- {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1, 2, 3, 4, 5 );
         boost::weak_ptr<X> wp( pi );
 
@@ -214,19 +134,6 @@
     }
 
     {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1+2+3+4+5 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
- {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1, 2, 3, 4, 5, 6 );
         boost::weak_ptr<X> wp( pi );
 
@@ -240,19 +147,6 @@
     }
 
     {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1+2+3+4+5+6 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
- {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7 );
         boost::weak_ptr<X> wp( pi );
 
@@ -266,19 +160,6 @@
     }
 
     {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1+2+3+4+5+6+7 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
- {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8 );
         boost::weak_ptr<X> wp( pi );
 
@@ -292,19 +173,6 @@
     }
 
     {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7, 8 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
- {
         boost::shared_ptr< X > pi = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
         boost::weak_ptr<X> wp( pi );
 
@@ -317,18 +185,5 @@
         BOOST_TEST( X::instances == 0 );
     }
 
- {
- boost::shared_ptr< X > pi = boost::allocate_shared< X >( std::allocator<void>(), 1, 2, 3, 4, 5, 6, 7, 8, 9 );
- boost::weak_ptr<X> wp( pi );
-
- BOOST_TEST( X::instances == 1 );
- BOOST_TEST( pi.get() != 0 );
- BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8+9 );
-
- pi.reset();
-
- BOOST_TEST( X::instances == 0 );
- }
-
     return boost::report_errors();
 }

Modified: trunk/libs/smart_ptr/test/smart_ptr_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/smart_ptr_test.cpp (original)
+++ trunk/libs/smart_ptr/test/smart_ptr_test.cpp 2008-05-03 15:29:01 EDT (Sat, 03 May 2008)
@@ -196,6 +196,10 @@
     BOOST_TEST( cp.use_count() == 3 );
     BOOST_TEST( *cp == 87654 );
 
+#if defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP )
+ using boost::swap;
+#endif
+
     boost::shared_ptr<int> cp4;
     swap( cp2, cp4 );
     BOOST_TEST( cp4.use_count() == 3 );

Modified: trunk/libs/smart_ptr/test/sp_unary_addr_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/sp_unary_addr_test.cpp (original)
+++ trunk/libs/smart_ptr/test/sp_unary_addr_test.cpp 2008-05-03 15:29:01 EDT (Sat, 03 May 2008)
@@ -49,6 +49,9 @@
         BOOST_TEST( q != 0 && q->data == 17041 );
     }
 
+#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
+#else
+
     {
         boost::shared_ptr<X> p( &x, deleter(), std::allocator<X>() );
 
@@ -58,5 +61,7 @@
         BOOST_TEST( q != 0 && q->data == 17041 );
     }
 
+#endif
+
     return boost::report_errors();
 }


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