Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81149 - in trunk: boost/smart_ptr boost/smart_ptr/detail libs/smart_ptr/test
From: pdimov_at_[hidden]
Date: 2012-11-02 13:41:39


Author: pdimov
Date: 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
New Revision: 81149
URL: http://svn.boost.org/trac/boost/changeset/81149

Log:
Implement shared_ptr<X[]>, weak_ptr<X[]>. Refs #1113.
Added:
   trunk/libs/smart_ptr/test/array_fail_ap_spa_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_ap_spa_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_ap_spa_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_ap_spa_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_array_access.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_dereference.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_member_access.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_sp_spa_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_sp_spa_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_sp_spa_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_sp_spa_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_sp_wpa_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_sp_wpa_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_sp_wpa_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_sp_wpa_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_sp_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_sp_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_sp_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_sp_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_spa_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_spa_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_spa_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_spa_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_wp_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_wp_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_wp_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_wp_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_wpa_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_wpa_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_wpa_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_spa_wpa_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_up_spa_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_up_spa_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_up_spa_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_up_spa_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_upa_sp_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_upa_sp_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_upa_sp_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_upa_sp_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wp_wpa_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wp_wpa_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wp_wpa_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wp_wpa_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wpa_wp_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wpa_wp_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wpa_wp_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wpa_wp_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wpa_wpa_a.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wpa_wpa_c.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wpa_wpa_ma.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/array_fail_wpa_wpa_mc.cpp (contents, props changed)
   trunk/libs/smart_ptr/test/sp_array_test.cpp (contents, props changed)
Text files modified:
   trunk/boost/smart_ptr/detail/operator_bool.hpp | 4
   trunk/boost/smart_ptr/detail/shared_count.hpp | 2
   trunk/boost/smart_ptr/shared_ptr.hpp | 203 +++++++++++++++++++++++++++++++--------
   trunk/boost/smart_ptr/weak_ptr.hpp | 19 ++
   trunk/libs/smart_ptr/test/Jamfile.v2 | 57 +++++++++++
   5 files changed, 235 insertions(+), 50 deletions(-)

Modified: trunk/boost/smart_ptr/detail/operator_bool.hpp
==============================================================================
--- trunk/boost/smart_ptr/detail/operator_bool.hpp (original)
+++ trunk/boost/smart_ptr/detail/operator_bool.hpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -31,7 +31,7 @@
     ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
     ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
 
- typedef T * (this_type::*unspecified_bool_type)() const;
+ typedef element_type * (this_type::*unspecified_bool_type)() const;
 
     operator unspecified_bool_type() const // never throws
     {
@@ -40,7 +40,7 @@
 
 #else
 
- typedef T * this_type::*unspecified_bool_type;
+ typedef element_type * this_type::*unspecified_bool_type;
 
     operator unspecified_bool_type() const // never throws
     {

Modified: trunk/boost/smart_ptr/detail/shared_count.hpp
==============================================================================
--- trunk/boost/smart_ptr/detail/shared_count.hpp (original)
+++ trunk/boost/smart_ptr/detail/shared_count.hpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -347,7 +347,7 @@
         typedef typename sp_convert_reference<D>::type D2;
 
         D2 d2( r.get_deleter() );
- pi_ = new sp_counted_impl_pd< Y*, D2 >( r.get(), d2 );
+ pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 );
 
 #ifdef BOOST_NO_EXCEPTIONS
 

Modified: trunk/boost/smart_ptr/shared_ptr.hpp
==============================================================================
--- trunk/boost/smart_ptr/shared_ptr.hpp (original)
+++ trunk/boost/smart_ptr/shared_ptr.hpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -67,34 +67,93 @@
 struct dynamic_cast_tag {};
 struct polymorphic_cast_tag {};
 
-template<class T> struct shared_ptr_traits
+// sp_element, element_type
+
+template< class T > struct sp_element
+{
+ typedef T type;
+};
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T > struct sp_element< T[] >
+{
+ typedef T type;
+};
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// sp_dereference, return type of operator*
+
+template< class T > struct sp_dereference
 {
- typedef T & reference;
+ typedef T & type;
 };
 
-template<> struct shared_ptr_traits<void>
+template<> struct sp_dereference< void >
 {
- typedef void reference;
+ typedef void type;
 };
 
 #if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
 
-template<> struct shared_ptr_traits<void const>
+template<> struct sp_dereference< void const >
 {
- typedef void reference;
+ typedef void type;
 };
 
-template<> struct shared_ptr_traits<void volatile>
+template<> struct sp_dereference< void volatile >
 {
- typedef void reference;
+ typedef void type;
 };
 
-template<> struct shared_ptr_traits<void const volatile>
+template<> struct sp_dereference< void const volatile >
 {
- typedef void reference;
+ typedef void type;
 };
 
-#endif
+#endif // !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T > struct sp_dereference< T[] >
+{
+ typedef void type;
+};
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// sp_member_access, return type of operator->
+
+template< class T > struct sp_member_access
+{
+ typedef T * type;
+};
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T > struct sp_member_access< T[] >
+{
+ typedef void type;
+};
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// sp_array_access, return type of operator[]
+
+template< class T > struct sp_array_access
+{
+ typedef void type;
+};
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T > struct sp_array_access< T[] >
+{
+ typedef T & type;
+};
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
 
 // enable_shared_from_this support
 
@@ -144,6 +203,47 @@
 
 #endif
 
+// sp_assert_convertible
+
+template< class T > inline void sp_assert_convertible( T * )
+{
+}
+
+// pointer constructor helper
+
+template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T > * ppx, Y * p, boost::detail::shared_count & pn )
+{
+ boost::detail::shared_count( p ).swap( pn );
+ boost::detail::sp_enable_shared_from_this( ppx, p, p );
+}
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T, class Y > inline void sp_pointer_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * p, boost::detail::shared_count & pn )
+{
+ sp_assert_convertible< T[] >( static_cast< Y (*) [] >( 0 ) );
+
+ boost::detail::shared_count( p, boost::checked_array_deleter< T >() ).swap( pn );
+}
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+// deleter constructor helper
+
+template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T > * ppx, Y * p )
+{
+ boost::detail::sp_enable_shared_from_this( ppx, p, p );
+}
+
+#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
+template< class T, class Y > inline void sp_deleter_construct( boost::shared_ptr< T[] > * /*ppx*/, Y * /*p*/ )
+{
+ sp_assert_convertible< T[] >( static_cast< Y (*) [] >( 0 ) );
+}
+
+#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
+
 } // namespace detail
 
 
@@ -164,19 +264,16 @@
 
 public:
 
- typedef T element_type;
- typedef T value_type;
- typedef T * pointer;
- typedef typename boost::detail::shared_ptr_traits<T>::reference reference;
+ typedef typename boost::detail::sp_element< T >::type element_type;
 
- shared_ptr(): px(0), pn() // never throws in 1.30+
+ shared_ptr(): px( 0 ), pn() // never throws in 1.30+
     {
     }
 
     template<class Y>
- explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete
+ explicit shared_ptr( Y * p ): px( p ), pn() // Y must be complete
     {
- boost::detail::sp_enable_shared_from_this( this, p, p );
+ boost::detail::sp_pointer_construct( this, p, pn );
     }
 
     //
@@ -185,16 +282,16 @@
     // shared_ptr will release p by calling d(p)
     //
 
- template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d)
+ template<class Y, class D> shared_ptr( Y * p, D d ): px( p ), pn( p, d )
     {
- boost::detail::sp_enable_shared_from_this( this, p, p );
+ boost::detail::sp_deleter_construct( this, p );
     }
 
     // As above, but with allocator. A's copy constructor shall not throw.
 
     template<class Y, class D, class A> shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a )
     {
- boost::detail::sp_enable_shared_from_this( this, p, p );
+ boost::detail::sp_deleter_construct( this, p );
     }
 
 // generated copy constructor, destructor are fine...
@@ -210,8 +307,10 @@
 #endif
 
     template<class Y>
- explicit shared_ptr(weak_ptr<Y> const & r): pn(r.pn) // may throw
+ explicit shared_ptr( weak_ptr<Y> const & r ): pn( r.pn ) // may throw
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
+
         // it is now safe to copy r.px, as pn(r.pn) did not throw
         px = r.px;
     }
@@ -237,11 +336,12 @@
 #endif
     : px( r.px ), pn( r.pn ) // never throws
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
     }
 
     // aliasing
     template< class Y >
- shared_ptr( shared_ptr<Y> const & r, T * p ): px( p ), pn( r.pn ) // never throws
+ shared_ptr( shared_ptr<Y> const & r, element_type * p ): px( p ), pn( r.pn ) // never throws
     {
     }
 
@@ -278,9 +378,12 @@
     template<class Y>
     explicit shared_ptr(std::auto_ptr<Y> & r): px(r.get()), pn()
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
+
         Y * tmp = r.get();
         pn = boost::detail::shared_count(r);
- boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
+
+ boost::detail::sp_deleter_construct( this, tmp );
     }
 
 #if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
@@ -288,11 +391,15 @@
     template<class Ap>
     explicit shared_ptr( Ap r, typename boost::detail::sp_enable_if_auto_ptr<Ap, int>::type = 0 ): px( r.get() ), pn()
     {
- typename Ap::element_type * tmp = r.get();
+ typedef typename Ap::element_type Y;
+
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
+
+ Y * tmp = r.get();
         pn = boost::detail::shared_count( r );
- boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
- }
 
+ boost::detail::sp_deleter_construct( this, tmp );
+ }
 
 #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
@@ -301,11 +408,14 @@
 #if !defined( BOOST_NO_CXX11_SMART_PTR )
 
     template< class Y, class D >
- shared_ptr( std::unique_ptr< Y, D > && r): px( r.get() ), pn()
+ shared_ptr( std::unique_ptr< Y, D > && r ): px( r.get() ), pn()
     {
- Y * tmp = r.get();
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
+
+ typename std::unique_ptr< Y, D >::pointer tmp = r.get();
         pn = boost::detail::shared_count( r );
- boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
+
+ boost::detail::sp_deleter_construct( this, tmp );
     }
 
 #endif
@@ -347,7 +457,6 @@
         return *this;
     }
 
-
 #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
 #endif // BOOST_NO_AUTO_PTR
@@ -374,6 +483,8 @@
 #endif
     : px( r.px ), pn() // never throws
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
+
         pn.swap( r.pn );
         r.px = 0;
     }
@@ -398,10 +509,10 @@
         this_type().swap(*this);
     }
 
- template<class Y> void reset(Y * p) // Y must be complete
+ template<class Y> void reset( Y * p ) // Y must be complete
     {
- BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors
- this_type(p).swap(*this);
+ BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
+ this_type( p ).swap( *this );
     }
 
     template<class Y, class D> void reset( Y * p, D d )
@@ -414,24 +525,32 @@
         this_type( p, d, a ).swap( *this );
     }
 
- template<class Y> void reset( shared_ptr<Y> const & r, T * p )
+ template<class Y> void reset( shared_ptr<Y> const & r, element_type * p )
     {
         this_type( r, p ).swap( *this );
     }
 
- reference operator* () const // never throws
+ typename boost::detail::sp_dereference< T >::type operator* () const // never throws
     {
- BOOST_ASSERT(px != 0);
+ BOOST_ASSERT( px != 0 );
         return *px;
     }
 
- T * operator-> () const // never throws
+ typename boost::detail::sp_member_access< T >::type operator-> () const // never throws
     {
- BOOST_ASSERT(px != 0);
+ BOOST_ASSERT( px != 0 );
         return px;
     }
 
- T * get() const // never throws
+ typename boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const // never throws
+ {
+ BOOST_ASSERT( px != 0 );
+ BOOST_ASSERT( i >= 0 );
+
+ return px[ i ];
+ }
+
+ element_type * get() const // never throws
     {
         return px;
     }
@@ -449,7 +568,7 @@
         return pn.use_count();
     }
 
- void swap(shared_ptr<T> & other) // never throws
+ void swap( shared_ptr & other ) // never throws
     {
         std::swap(px, other.px);
         pn.swap(other.pn);
@@ -488,7 +607,7 @@
 
 #endif
 
- T * px; // contained pointer
+ element_type * px; // contained pointer
     boost::detail::shared_count pn; // reference counter
 
 }; // shared_ptr

Modified: trunk/boost/smart_ptr/weak_ptr.hpp
==============================================================================
--- trunk/boost/smart_ptr/weak_ptr.hpp (original)
+++ trunk/boost/smart_ptr/weak_ptr.hpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -29,7 +29,7 @@
 
 public:
 
- typedef T element_type;
+ typedef typename boost::detail::sp_element< T >::type element_type;
 
     weak_ptr(): px(0), pn() // never throws in 1.30+
     {
@@ -83,6 +83,7 @@
 #endif
     : px(r.lock().get()), pn(r.pn) // never throws
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
     }
 
 #if defined( BOOST_HAS_RVALUE_REFS )
@@ -99,6 +100,7 @@
 #endif
     : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) // never throws
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
         r.px = 0;
     }
 
@@ -130,15 +132,19 @@
 #endif
     : px( r.px ), pn( r.pn ) // never throws
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
     }
 
 #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
 
     template<class Y>
- weak_ptr & operator=(weak_ptr<Y> const & r) // never throws
+ weak_ptr & operator=( weak_ptr<Y> const & r ) // never throws
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
+
         px = r.lock().get();
         pn = r.pn;
+
         return *this;
     }
 
@@ -154,10 +160,13 @@
 #endif
 
     template<class Y>
- weak_ptr & operator=(shared_ptr<Y> const & r) // never throws
+ weak_ptr & operator=( shared_ptr<Y> const & r ) // never throws
     {
+ boost::detail::sp_assert_convertible< T >( static_cast< Y* >( 0 ) );
+
         px = r.px;
         pn = r.pn;
+
         return *this;
     }
 
@@ -165,7 +174,7 @@
 
     shared_ptr<T> lock() const // never throws
     {
- return shared_ptr<element_type>( *this, boost::detail::sp_nothrow_tag() );
+ return shared_ptr<T>( *this, boost::detail::sp_nothrow_tag() );
     }
 
     long use_count() const // never throws
@@ -223,7 +232,7 @@
 
 #endif
 
- T * px; // contained pointer
+ element_type * px; // contained pointer
     boost::detail::weak_count pn; // reference counter
 
 }; // weak_ptr

Modified: trunk/libs/smart_ptr/test/Jamfile.v2
==============================================================================
--- trunk/libs/smart_ptr/test/Jamfile.v2 (original)
+++ trunk/libs/smart_ptr/test/Jamfile.v2 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -70,5 +70,62 @@
           [ run ip_hash_test.cpp ]
           [ run owner_less_test.cpp ]
           [ run sp_unique_ptr_test.cpp ]
+ [ run sp_array_test.cpp ]
+
+ [ compile-fail array_fail_spa_sp_c.cpp ]
+ [ compile-fail array_fail_sp_spa_c.cpp ]
+ [ compile-fail array_fail_spa_spa_c.cpp ]
+ [ compile-fail array_fail_spa_wp_c.cpp ]
+ [ compile-fail array_fail_sp_wpa_c.cpp ]
+ [ compile-fail array_fail_spa_wpa_c.cpp ]
+ [ compile-fail array_fail_wpa_wp_c.cpp ]
+ [ compile-fail array_fail_wp_wpa_c.cpp ]
+ [ compile-fail array_fail_wpa_wpa_c.cpp ]
+ [ compile-fail array_fail_ap_spa_c.cpp ]
+ [ compile-fail array_fail_upa_sp_c.cpp ]
+ [ compile-fail array_fail_up_spa_c.cpp ]
+
+ [ compile-fail array_fail_spa_sp_mc.cpp ]
+ [ compile-fail array_fail_sp_spa_mc.cpp ]
+ [ compile-fail array_fail_spa_spa_mc.cpp ]
+ [ compile-fail array_fail_spa_wp_mc.cpp ]
+ [ compile-fail array_fail_sp_wpa_mc.cpp ]
+ [ compile-fail array_fail_spa_wpa_mc.cpp ]
+ [ compile-fail array_fail_wpa_wp_mc.cpp ]
+ [ compile-fail array_fail_wp_wpa_mc.cpp ]
+ [ compile-fail array_fail_wpa_wpa_mc.cpp ]
+ [ compile-fail array_fail_ap_spa_mc.cpp ]
+ [ compile-fail array_fail_upa_sp_mc.cpp ]
+ [ compile-fail array_fail_up_spa_mc.cpp ]
+
+ [ compile-fail array_fail_spa_sp_a.cpp ]
+ [ compile-fail array_fail_sp_spa_a.cpp ]
+ [ compile-fail array_fail_spa_spa_a.cpp ]
+ [ compile-fail array_fail_spa_wp_a.cpp ]
+ [ compile-fail array_fail_sp_wpa_a.cpp ]
+ [ compile-fail array_fail_spa_wpa_a.cpp ]
+ [ compile-fail array_fail_wpa_wp_a.cpp ]
+ [ compile-fail array_fail_wp_wpa_a.cpp ]
+ [ compile-fail array_fail_wpa_wpa_a.cpp ]
+ [ compile-fail array_fail_ap_spa_a.cpp ]
+ [ compile-fail array_fail_upa_sp_a.cpp ]
+ [ compile-fail array_fail_up_spa_a.cpp ]
+
+ [ compile-fail array_fail_spa_sp_ma.cpp ]
+ [ compile-fail array_fail_sp_spa_ma.cpp ]
+ [ compile-fail array_fail_spa_spa_ma.cpp ]
+ [ compile-fail array_fail_spa_wp_ma.cpp ]
+ [ compile-fail array_fail_sp_wpa_ma.cpp ]
+ [ compile-fail array_fail_spa_wpa_ma.cpp ]
+ [ compile-fail array_fail_wpa_wp_ma.cpp ]
+ [ compile-fail array_fail_wp_wpa_ma.cpp ]
+ [ compile-fail array_fail_wpa_wpa_ma.cpp ]
+ [ compile-fail array_fail_ap_spa_ma.cpp ]
+ [ compile-fail array_fail_upa_sp_ma.cpp ]
+ [ compile-fail array_fail_up_spa_ma.cpp ]
+
+ [ compile-fail array_fail_dereference.cpp ]
+ [ compile-fail array_fail_member_access.cpp ]
+ [ compile-fail array_fail_array_access.cpp ]
         ;
 }

Added: trunk/libs/smart_ptr/test/array_fail_ap_spa_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_ap_spa_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ std::auto_ptr<X> px;
+ boost::shared_ptr<X[]> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_ap_spa_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_ap_spa_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ std::auto_ptr<X> px;
+ boost::shared_ptr<X[]> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_ap_spa_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_ap_spa_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px2; px2 = std::auto_ptr<X>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_ap_spa_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_ap_spa_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px2(( std::auto_ptr<X>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_array_access.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_array_access.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px( new X );
+ px[ 0 ];
+}

Added: trunk/libs/smart_ptr/test/array_fail_dereference.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_dereference.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px( new X[ 1 ] );
+ *px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_member_access.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_member_access.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+ int m;
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px( new X[ 1 ] );
+ px->m = 0;
+}

Added: trunk/libs/smart_ptr/test/array_fail_sp_spa_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_sp_spa_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px;
+ boost::shared_ptr<X[]> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_sp_spa_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_sp_spa_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px;
+ boost::shared_ptr<X[]> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_sp_spa_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_sp_spa_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px2; px2 = boost::shared_ptr<X>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_sp_spa_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_sp_spa_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px2(( boost::shared_ptr<X>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_sp_wpa_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_sp_wpa_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px;
+ boost::weak_ptr<X[]> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_sp_wpa_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_sp_wpa_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px;
+ boost::weak_ptr<X[]> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_sp_wpa_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_sp_wpa_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px2; px2 = boost::shared_ptr<X>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_sp_wpa_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_sp_wpa_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px2(( boost::shared_ptr<X>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_sp_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_sp_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px;
+ boost::shared_ptr<X> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_sp_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_sp_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px;
+ boost::shared_ptr<X> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_sp_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_sp_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px2; px2 = boost::shared_ptr<X[]>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_sp_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_sp_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px2(( boost::shared_ptr<X[]>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_spa_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_spa_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,23 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<Y[]> px;
+ boost::shared_ptr<X[]> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_spa_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_spa_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,23 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<Y[]> px;
+ boost::shared_ptr<X[]> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_spa_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_spa_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,22 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px2; px2 = boost::shared_ptr<Y[]>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_spa_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_spa_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,22 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px2(( boost::shared_ptr<Y[]>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_wp_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_wp_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px;
+ boost::weak_ptr<X> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_wp_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_wp_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px;
+ boost::weak_ptr<X> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_wp_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_wp_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X> px2; px2 = boost::shared_ptr<X[]>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_wp_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_wp_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X> px2(( boost::shared_ptr<X[]>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_wpa_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_wpa_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,24 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<Y[]> px;
+ boost::weak_ptr<X[]> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_wpa_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_wpa_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,24 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<Y[]> px;
+ boost::weak_ptr<X[]> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_wpa_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_wpa_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,23 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px2; px2 = boost::shared_ptr<Y[]>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_spa_wpa_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_spa_wpa_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,23 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px2(( boost::shared_ptr<Y[]>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_up_spa_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_up_spa_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ std::unique_ptr<X> px;
+ boost::shared_ptr<X[]> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_up_spa_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_up_spa_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ std::unique_ptr<X> px;
+ boost::shared_ptr<X[]> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_up_spa_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_up_spa_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px2; px2 = std::unique_ptr<X>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_up_spa_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_up_spa_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X[]> px2(( std::unique_ptr<X>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_upa_sp_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_upa_sp_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ std::unique_ptr<X[]> px;
+ boost::shared_ptr<X> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_upa_sp_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_upa_sp_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,20 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ std::unique_ptr<X[]> px;
+ boost::shared_ptr<X> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_upa_sp_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_upa_sp_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px2; px2 = std::unique_ptr<X[]>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_upa_sp_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_upa_sp_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <memory>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::shared_ptr<X> px2(( std::unique_ptr<X[]>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_wp_wpa_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wp_wpa_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X> px;
+ boost::weak_ptr<X[]> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_wp_wpa_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wp_wpa_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X> px;
+ boost::weak_ptr<X[]> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_wp_wpa_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wp_wpa_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px2; px2 = boost::weak_ptr<X>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_wp_wpa_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wp_wpa_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px2(( boost::weak_ptr<X>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_wpa_wp_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wpa_wp_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px;
+ boost::weak_ptr<X> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_wpa_wp_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wpa_wp_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,19 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px;
+ boost::weak_ptr<X> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_wpa_wp_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wpa_wp_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X> px2; px2 = boost::weak_ptr<X[]>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_wpa_wp_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wpa_wp_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,18 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X> px2(( boost::weak_ptr<X[]>() ));
+}

Added: trunk/libs/smart_ptr/test/array_fail_wpa_wpa_a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wpa_wpa_a.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,23 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<Y[]> px;
+ boost::weak_ptr<X[]> px2; px2 = px;
+}

Added: trunk/libs/smart_ptr/test/array_fail_wpa_wpa_c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wpa_wpa_c.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,23 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<Y[]> px;
+ boost::weak_ptr<X[]> px2( px );
+}

Added: trunk/libs/smart_ptr/test/array_fail_wpa_wpa_ma.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wpa_wpa_ma.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,22 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px2; px2 = boost::weak_ptr<Y[]>();
+}

Added: trunk/libs/smart_ptr/test/array_fail_wpa_wpa_mc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/array_fail_wpa_wpa_mc.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,22 @@
+//
+// Copyright (c) 2012 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/weak_ptr.hpp>
+
+struct X
+{
+};
+
+struct Y: public X
+{
+};
+
+int main()
+{
+ boost::weak_ptr<X[]> px2(( boost::weak_ptr<Y[]>() ));
+}

Added: trunk/libs/smart_ptr/test/sp_array_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/sp_array_test.cpp 2012-11-02 13:41:33 EDT (Fri, 02 Nov 2012)
@@ -0,0 +1,291 @@
+//
+// sp_array_test.cpp
+//
+// Copyright (c) 2012 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/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <boost/enable_shared_from_this.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <memory>
+#include <utility>
+
+class X: public boost::enable_shared_from_this< X >
+{
+public:
+
+ static int allocations;
+ static int instances;
+
+ X()
+ {
+ ++instances;
+ }
+
+ ~X()
+ {
+ --instances;
+ }
+
+ void* operator new[]( std::size_t n )
+ {
+ ++allocations;
+ return ::operator new[]( n );
+ }
+
+ void operator delete[]( void* p )
+ {
+ --allocations;
+ ::operator delete[]( p );
+ }
+
+private:
+
+ X( X const& );
+ X& operator=( X const& );
+};
+
+int X::allocations = 0;
+int X::instances = 0;
+
+template< class T> class array_deleter
+{
+public:
+
+ static int calls;
+
+ void operator()( T * p ) const
+ {
+ ++calls;
+ delete[] p;
+ }
+
+private:
+
+ template< class Y > void operator()( Y * p ) const;
+};
+
+template< class T > int array_deleter< T >::calls = 0;
+
+int main()
+{
+ BOOST_TEST( X::allocations == 0 );
+ BOOST_TEST( X::instances == 0 );
+
+ {
+ boost::shared_ptr<X[]> px;
+ BOOST_TEST( !px );
+
+ BOOST_TEST( X::allocations == 0 );
+ BOOST_TEST( X::instances == 0 );
+
+ boost::shared_ptr<X[]> px2( new X[ 3 ] );
+ BOOST_TEST( px2 );
+
+ try
+ {
+ px2[0].shared_from_this();
+ BOOST_ERROR( "px2[0].shared_from_this() failed to throw" );
+ }
+ catch( boost::bad_weak_ptr const& )
+ {
+ }
+
+ BOOST_TEST( X::allocations == 1 );
+ BOOST_TEST( X::instances == 3 );
+
+ {
+ X & rx = px2[ 0 ];
+ BOOST_TEST( &rx == px2.get() );
+ }
+
+ boost::shared_ptr<X const[]> px3( px2 );
+ BOOST_TEST( px3 == px2 );
+ BOOST_TEST( !( px2 < px3 ) && !( px3 < px2 ) );
+
+ {
+ X const & rx = px3[ 1 ];
+ BOOST_TEST( &rx == px3.get() + 1 );
+ }
+
+ px3.reset();
+ px3 = px2;
+ BOOST_TEST( px3 == px2 );
+ BOOST_TEST( !( px2 < px3 ) && !( px3 < px2 ) );
+
+ boost::shared_ptr<X volatile[]> px4( px2 );
+ BOOST_TEST( px4 == px2 );
+ BOOST_TEST( !( px2 < px4 ) && !( px4 < px2 ) );
+
+ {
+ X volatile & rx = px4[ 2 ];
+ BOOST_TEST( &rx == px4.get() + 2 );
+ }
+
+ px4.reset();
+ px4 = px2;
+ BOOST_TEST( px4 == px2 );
+ BOOST_TEST( !( px2 < px4 ) && !( px4 < px2 ) );
+
+ boost::shared_ptr<void> px5( px2 );
+ BOOST_TEST( px5 == px2 );
+ BOOST_TEST( !( px2 < px5 ) && !( px5 < px2 ) );
+
+ px5.reset();
+ px5 = px2;
+ BOOST_TEST( px5 == px2 );
+ BOOST_TEST( !( px2 < px5 ) && !( px5 < px2 ) );
+
+ boost::weak_ptr<X[]> wp( px );
+ BOOST_TEST( wp.lock() == px );
+
+ boost::weak_ptr<X[]> wp2( px2 );
+ BOOST_TEST( wp2.lock() == px2 );
+
+ wp2.reset();
+ wp2 = px2;
+ BOOST_TEST( wp2.lock() == px2 );
+
+ boost::weak_ptr<X const[]> wp3( px2 );
+ BOOST_TEST( wp3.lock() == px2 );
+
+ wp3.reset();
+ wp3 = px2;
+ BOOST_TEST( wp3.lock() == px2 );
+
+ boost::weak_ptr<X volatile[]> wp4( px2 );
+ BOOST_TEST( wp4.lock() == px2 );
+
+ wp4.reset();
+ wp4 = px2;
+ BOOST_TEST( wp4.lock() == px2 );
+
+ boost::weak_ptr<void> wp5( px2 );
+ BOOST_TEST( wp5.lock() == px2 );
+
+ wp5.reset();
+ wp5 = px2;
+ BOOST_TEST( wp5.lock() == px2 );
+
+ px2.reset();
+
+ BOOST_TEST( X::allocations == 1 );
+ BOOST_TEST( X::instances == 3 );
+
+ px3.reset();
+ px4.reset();
+ px5.reset();
+
+ BOOST_TEST( X::allocations == 0 );
+ BOOST_TEST( X::instances == 0 );
+
+ BOOST_TEST( wp2.lock() == 0 );
+ BOOST_TEST( wp3.lock() == 0 );
+ BOOST_TEST( wp4.lock() == 0 );
+ BOOST_TEST( wp5.lock() == 0 );
+ }
+
+#if !defined( BOOST_NO_CXX11_SMART_PTR )
+
+ {
+ std::unique_ptr<X[]> px( new X[ 4 ] );
+ BOOST_TEST( X::allocations == 1 );
+ BOOST_TEST( X::instances == 4 );
+
+ boost::shared_ptr<X[]> px2( std::move( px ) );
+ BOOST_TEST( X::allocations == 1 );
+ BOOST_TEST( X::instances == 4 );
+ BOOST_TEST( px.get() == 0 );
+
+ try
+ {
+ px2[0].shared_from_this();
+ BOOST_ERROR( "px2[0].shared_from_this() failed to throw" );
+ }
+ catch( boost::bad_weak_ptr const& )
+ {
+ }
+
+ px2.reset();
+
+ BOOST_TEST( X::allocations == 0 );
+ BOOST_TEST( X::instances == 0 );
+ }
+
+ {
+ std::unique_ptr<X[]> px( new X[ 4 ] );
+ BOOST_TEST( X::allocations == 1 );
+ BOOST_TEST( X::instances == 4 );
+
+ boost::shared_ptr<X[]> px2;
+ px2 = std::move( px );
+ BOOST_TEST( X::allocations == 1 );
+ BOOST_TEST( X::instances == 4 );
+ BOOST_TEST( px.get() == 0 );
+
+ try
+ {
+ px2[0].shared_from_this();
+ BOOST_ERROR( "px2[0].shared_from_this() failed to throw" );
+ }
+ catch( boost::bad_weak_ptr const& )
+ {
+ }
+
+ px2.reset();
+
+ BOOST_TEST( X::allocations == 0 );
+ BOOST_TEST( X::instances == 0 );
+ }
+
+#endif
+
+ {
+ boost::shared_ptr<X[]> px( new X[ 5 ], array_deleter< X >() );
+ BOOST_TEST( X::allocations == 1 );
+ BOOST_TEST( X::instances == 5 );
+
+ try
+ {
+ px[0].shared_from_this();
+ BOOST_ERROR( "px[0].shared_from_this() failed to throw" );
+ }
+ catch( boost::bad_weak_ptr const& )
+ {
+ }
+
+ px.reset();
+
+ BOOST_TEST( X::allocations == 0 );
+ BOOST_TEST( X::instances == 0 );
+ BOOST_TEST( array_deleter< X >::calls == 1 );
+ }
+
+ {
+ boost::shared_ptr<X[]> px( new X[ 6 ], array_deleter< X >(), std::allocator< X >() );
+ BOOST_TEST( X::allocations == 1 );
+ BOOST_TEST( X::instances == 6 );
+
+ try
+ {
+ px[0].shared_from_this();
+ BOOST_ERROR( "px[0].shared_from_this() failed to throw" );
+ }
+ catch( boost::bad_weak_ptr const& )
+ {
+ }
+
+ px.reset();
+
+ BOOST_TEST( X::allocations == 0 );
+ BOOST_TEST( X::instances == 0 );
+ BOOST_TEST( array_deleter< X >::calls == 2 );
+ }
+
+ 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