mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-29 20:37:13 +02:00
@ -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
|
||||
{
|
||||
|
@ -347,7 +347,7 @@ public:
|
||||
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
|
||||
|
||||
|
@ -67,34 +67,93 @@ struct const_cast_tag {};
|
||||
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 & reference;
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<> struct shared_ptr_traits<void>
|
||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
template< class T > struct sp_element< T[] >
|
||||
{
|
||||
typedef void reference;
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
#endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
||||
|
||||
// sp_dereference, return type of operator*
|
||||
|
||||
template< class T > struct sp_dereference
|
||||
{
|
||||
typedef T & type;
|
||||
};
|
||||
|
||||
template<> struct sp_dereference< void >
|
||||
{
|
||||
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 @@ template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R
|
||||
|
||||
#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 @@ private:
|
||||
|
||||
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 @@ public:
|
||||
// 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 @@ public:
|
||||
#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 @@ public:
|
||||
#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 @@ public:
|
||||
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 @@ public:
|
||||
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();
|
||||
pn = boost::detail::shared_count( r );
|
||||
boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
|
||||
}
|
||||
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_deleter_construct( this, tmp );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
@ -301,11 +408,14 @@ public:
|
||||
#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 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif // BOOST_NO_AUTO_PTR
|
||||
@ -374,6 +483,8 @@ public:
|
||||
#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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
T * px; // contained pointer
|
||||
element_type * px; // contained pointer
|
||||
boost::detail::shared_count pn; // reference counter
|
||||
|
||||
}; // shared_ptr
|
||||
|
@ -29,7 +29,7 @@ private:
|
||||
|
||||
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 @@ public:
|
||||
#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 @@ public:
|
||||
#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 @@ public:
|
||||
#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 @@ public:
|
||||
#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 @@ public:
|
||||
|
||||
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 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
T * px; // contained pointer
|
||||
element_type * px; // contained pointer
|
||||
boost::detail::weak_count pn; // reference counter
|
||||
|
||||
}; // weak_ptr
|
||||
|
@ -70,5 +70,62 @@ import testing ;
|
||||
[ 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 ]
|
||||
;
|
||||
}
|
||||
|
20
test/array_fail_ap_spa_a.cpp
Normal file
20
test/array_fail_ap_spa_a.cpp
Normal file
@ -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;
|
||||
}
|
20
test/array_fail_ap_spa_c.cpp
Normal file
20
test/array_fail_ap_spa_c.cpp
Normal file
@ -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 );
|
||||
}
|
19
test/array_fail_ap_spa_ma.cpp
Normal file
19
test/array_fail_ap_spa_ma.cpp
Normal file
@ -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>();
|
||||
}
|
19
test/array_fail_ap_spa_mc.cpp
Normal file
19
test/array_fail_ap_spa_mc.cpp
Normal file
@ -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>() ));
|
||||
}
|
19
test/array_fail_array_access.cpp
Normal file
19
test/array_fail_array_access.cpp
Normal file
@ -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 ];
|
||||
}
|
19
test/array_fail_dereference.cpp
Normal file
19
test/array_fail_dereference.cpp
Normal file
@ -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;
|
||||
}
|
20
test/array_fail_member_access.cpp
Normal file
20
test/array_fail_member_access.cpp
Normal file
@ -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;
|
||||
}
|
19
test/array_fail_sp_spa_a.cpp
Normal file
19
test/array_fail_sp_spa_a.cpp
Normal file
@ -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;
|
||||
}
|
19
test/array_fail_sp_spa_c.cpp
Normal file
19
test/array_fail_sp_spa_c.cpp
Normal file
@ -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 );
|
||||
}
|
18
test/array_fail_sp_spa_ma.cpp
Normal file
18
test/array_fail_sp_spa_ma.cpp
Normal file
@ -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>();
|
||||
}
|
18
test/array_fail_sp_spa_mc.cpp
Normal file
18
test/array_fail_sp_spa_mc.cpp
Normal file
@ -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>() ));
|
||||
}
|
20
test/array_fail_sp_wpa_a.cpp
Normal file
20
test/array_fail_sp_wpa_a.cpp
Normal file
@ -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;
|
||||
}
|
20
test/array_fail_sp_wpa_c.cpp
Normal file
20
test/array_fail_sp_wpa_c.cpp
Normal file
@ -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 );
|
||||
}
|
19
test/array_fail_sp_wpa_ma.cpp
Normal file
19
test/array_fail_sp_wpa_ma.cpp
Normal file
@ -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>();
|
||||
}
|
19
test/array_fail_sp_wpa_mc.cpp
Normal file
19
test/array_fail_sp_wpa_mc.cpp
Normal file
@ -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>() ));
|
||||
}
|
19
test/array_fail_spa_sp_a.cpp
Normal file
19
test/array_fail_spa_sp_a.cpp
Normal file
@ -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;
|
||||
}
|
19
test/array_fail_spa_sp_c.cpp
Normal file
19
test/array_fail_spa_sp_c.cpp
Normal file
@ -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 );
|
||||
}
|
18
test/array_fail_spa_sp_ma.cpp
Normal file
18
test/array_fail_spa_sp_ma.cpp
Normal file
@ -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[]>();
|
||||
}
|
18
test/array_fail_spa_sp_mc.cpp
Normal file
18
test/array_fail_spa_sp_mc.cpp
Normal file
@ -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[]>() ));
|
||||
}
|
23
test/array_fail_spa_spa_a.cpp
Normal file
23
test/array_fail_spa_spa_a.cpp
Normal file
@ -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;
|
||||
}
|
23
test/array_fail_spa_spa_c.cpp
Normal file
23
test/array_fail_spa_spa_c.cpp
Normal file
@ -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 );
|
||||
}
|
22
test/array_fail_spa_spa_ma.cpp
Normal file
22
test/array_fail_spa_spa_ma.cpp
Normal file
@ -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[]>();
|
||||
}
|
22
test/array_fail_spa_spa_mc.cpp
Normal file
22
test/array_fail_spa_spa_mc.cpp
Normal file
@ -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[]>() ));
|
||||
}
|
20
test/array_fail_spa_wp_a.cpp
Normal file
20
test/array_fail_spa_wp_a.cpp
Normal file
@ -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;
|
||||
}
|
20
test/array_fail_spa_wp_c.cpp
Normal file
20
test/array_fail_spa_wp_c.cpp
Normal file
@ -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 );
|
||||
}
|
19
test/array_fail_spa_wp_ma.cpp
Normal file
19
test/array_fail_spa_wp_ma.cpp
Normal file
@ -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[]>();
|
||||
}
|
19
test/array_fail_spa_wp_mc.cpp
Normal file
19
test/array_fail_spa_wp_mc.cpp
Normal file
@ -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[]>() ));
|
||||
}
|
24
test/array_fail_spa_wpa_a.cpp
Normal file
24
test/array_fail_spa_wpa_a.cpp
Normal file
@ -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;
|
||||
}
|
24
test/array_fail_spa_wpa_c.cpp
Normal file
24
test/array_fail_spa_wpa_c.cpp
Normal file
@ -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 );
|
||||
}
|
23
test/array_fail_spa_wpa_ma.cpp
Normal file
23
test/array_fail_spa_wpa_ma.cpp
Normal file
@ -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[]>();
|
||||
}
|
23
test/array_fail_spa_wpa_mc.cpp
Normal file
23
test/array_fail_spa_wpa_mc.cpp
Normal file
@ -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[]>() ));
|
||||
}
|
20
test/array_fail_up_spa_a.cpp
Normal file
20
test/array_fail_up_spa_a.cpp
Normal file
@ -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;
|
||||
}
|
20
test/array_fail_up_spa_c.cpp
Normal file
20
test/array_fail_up_spa_c.cpp
Normal file
@ -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 );
|
||||
}
|
19
test/array_fail_up_spa_ma.cpp
Normal file
19
test/array_fail_up_spa_ma.cpp
Normal file
@ -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>();
|
||||
}
|
19
test/array_fail_up_spa_mc.cpp
Normal file
19
test/array_fail_up_spa_mc.cpp
Normal file
@ -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>() ));
|
||||
}
|
20
test/array_fail_upa_sp_a.cpp
Normal file
20
test/array_fail_upa_sp_a.cpp
Normal file
@ -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;
|
||||
}
|
20
test/array_fail_upa_sp_c.cpp
Normal file
20
test/array_fail_upa_sp_c.cpp
Normal file
@ -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 );
|
||||
}
|
19
test/array_fail_upa_sp_ma.cpp
Normal file
19
test/array_fail_upa_sp_ma.cpp
Normal file
@ -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[]>();
|
||||
}
|
19
test/array_fail_upa_sp_mc.cpp
Normal file
19
test/array_fail_upa_sp_mc.cpp
Normal file
@ -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[]>() ));
|
||||
}
|
19
test/array_fail_wp_wpa_a.cpp
Normal file
19
test/array_fail_wp_wpa_a.cpp
Normal file
@ -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;
|
||||
}
|
19
test/array_fail_wp_wpa_c.cpp
Normal file
19
test/array_fail_wp_wpa_c.cpp
Normal file
@ -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 );
|
||||
}
|
18
test/array_fail_wp_wpa_ma.cpp
Normal file
18
test/array_fail_wp_wpa_ma.cpp
Normal file
@ -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>();
|
||||
}
|
18
test/array_fail_wp_wpa_mc.cpp
Normal file
18
test/array_fail_wp_wpa_mc.cpp
Normal file
@ -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>() ));
|
||||
}
|
19
test/array_fail_wpa_wp_a.cpp
Normal file
19
test/array_fail_wpa_wp_a.cpp
Normal file
@ -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;
|
||||
}
|
19
test/array_fail_wpa_wp_c.cpp
Normal file
19
test/array_fail_wpa_wp_c.cpp
Normal file
@ -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 );
|
||||
}
|
18
test/array_fail_wpa_wp_ma.cpp
Normal file
18
test/array_fail_wpa_wp_ma.cpp
Normal file
@ -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[]>();
|
||||
}
|
18
test/array_fail_wpa_wp_mc.cpp
Normal file
18
test/array_fail_wpa_wp_mc.cpp
Normal file
@ -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[]>() ));
|
||||
}
|
23
test/array_fail_wpa_wpa_a.cpp
Normal file
23
test/array_fail_wpa_wpa_a.cpp
Normal file
@ -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;
|
||||
}
|
23
test/array_fail_wpa_wpa_c.cpp
Normal file
23
test/array_fail_wpa_wpa_c.cpp
Normal file
@ -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 );
|
||||
}
|
22
test/array_fail_wpa_wpa_ma.cpp
Normal file
22
test/array_fail_wpa_wpa_ma.cpp
Normal file
@ -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[]>();
|
||||
}
|
22
test/array_fail_wpa_wpa_mc.cpp
Normal file
22
test/array_fail_wpa_wpa_mc.cpp
Normal file
@ -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[]>() ));
|
||||
}
|
291
test/sp_array_test.cpp
Normal file
291
test/sp_array_test.cpp
Normal file
@ -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();
|
||||
}
|
Reference in New Issue
Block a user