Merge branch 'develop'

This commit is contained in:
Peter Dimov committed 2017-01-01 04:10:26 +02:00
commit 39b14fa0d6
26 files changed
+416 -60

No files matched your search

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,30 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_NOEXCEPT_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_NOEXCEPT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_noexcept.hpp
//
// Copyright 2016 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/config.hpp>
#if defined( BOOST_MSVC ) && BOOST_MSVC >= 1700 && BOOST_MSVC < 1900
#define BOOST_SP_NOEXCEPT BOOST_NOEXCEPT_OR_NOTHROW
#else
#define BOOST_SP_NOEXCEPT BOOST_NOEXCEPT
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_NOEXCEPT_HPP_INCLUDED
@@ -15,6 +15,7 @@
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
@@ -25,20 +26,20 @@ template<class T> class enable_shared_from_this
{
protected:
enable_shared_from_this() BOOST_NOEXCEPT
enable_shared_from_this() BOOST_SP_NOEXCEPT
{
}
enable_shared_from_this(enable_shared_from_this const &) BOOST_NOEXCEPT
enable_shared_from_this(enable_shared_from_this const &) BOOST_SP_NOEXCEPT
{
}
enable_shared_from_this & operator=(enable_shared_from_this const &) BOOST_NOEXCEPT
enable_shared_from_this & operator=(enable_shared_from_this const &) BOOST_SP_NOEXCEPT
{
return *this;
}
~enable_shared_from_this() BOOST_NOEXCEPT // ~weak_ptr<T> newer throws, so this call also must not throw
~enable_shared_from_this() BOOST_SP_NOEXCEPT // ~weak_ptr<T> newer throws, so this call also must not throw
{
}
+4 -3
View File
@@ -19,6 +19,7 @@
#include <boost/detail/workaround.hpp>
#include <boost/smart_ptr/detail/sp_convertible.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/config/no_tr1/functional.hpp> // for std::less
@@ -59,7 +60,7 @@ public:
typedef T element_type;
BOOST_CONSTEXPR intrusive_ptr() BOOST_NOEXCEPT : px( 0 )
BOOST_CONSTEXPR intrusive_ptr() BOOST_SP_NOEXCEPT : px( 0 )
{
}
@@ -111,12 +112,12 @@ public:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
intrusive_ptr(intrusive_ptr && rhs) BOOST_NOEXCEPT : px( rhs.px )
intrusive_ptr(intrusive_ptr && rhs) BOOST_SP_NOEXCEPT : px( rhs.px )
{
rhs.px = 0;
}
intrusive_ptr & operator=(intrusive_ptr && rhs) BOOST_NOEXCEPT
intrusive_ptr & operator=(intrusive_ptr && rhs) BOOST_SP_NOEXCEPT
{
this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this);
return *this;
+11 -34
View File
@@ -5,6 +5,7 @@
// owner_less.hpp
//
// Copyright (c) 2008 Frank Mori Hess
// Copyright (c) 2016 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -13,44 +14,20 @@
// See http://www.boost.org/libs/smart_ptr/smart_ptr.htm for documentation.
//
#include <functional>
namespace boost
{
template<typename T> class shared_ptr;
template<typename T> class weak_ptr;
namespace detail
{
template<typename T, typename U>
struct generic_owner_less : public std::binary_function<T, T, bool>
template<class T = void> struct owner_less
{
typedef bool result_type;
typedef T first_argument_type;
typedef T second_argument_type;
template<class U, class V> bool operator()( U const & u, V const & v ) const
{
bool operator()(const T &lhs, const T &rhs) const
{
return lhs.owner_before(rhs);
}
bool operator()(const T &lhs, const U &rhs) const
{
return lhs.owner_before(rhs);
}
bool operator()(const U &lhs, const T &rhs) const
{
return lhs.owner_before(rhs);
}
};
} // namespace detail
template<typename T> struct owner_less;
template<typename T>
struct owner_less<shared_ptr<T> >:
public detail::generic_owner_less<shared_ptr<T>, weak_ptr<T> >
{};
template<typename T>
struct owner_less<weak_ptr<T> >:
public detail::generic_owner_less<weak_ptr<T>, shared_ptr<T> >
{};
return u.owner_before( v );
}
};
} // namespace boost
+2 -1
View File
@@ -15,6 +15,7 @@
#include <boost/assert.hpp>
#include <boost/checked_delete.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/detail/workaround.hpp>
@@ -54,7 +55,7 @@ public:
typedef T element_type;
explicit scoped_array( T * p = 0 ) BOOST_NOEXCEPT : px( p )
explicit scoped_array( T * p = 0 ) BOOST_SP_NOEXCEPT : px( p )
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_array_constructor_hook( px );
+2 -1
View File
@@ -16,6 +16,7 @@
#include <boost/checked_delete.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/detail/workaround.hpp>
#ifndef BOOST_NO_AUTO_PTR
@@ -62,7 +63,7 @@ public:
typedef T element_type;
explicit scoped_ptr( T * p = 0 ): px( p ) // never throws
explicit scoped_ptr( T * p = 0 ) BOOST_SP_NOEXCEPT : px( p ) // never throws
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_constructor_hook( px );
+7 -6
View File
@@ -24,6 +24,7 @@
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/detail/workaround.hpp>
#include <cstddef> // for std::ptrdiff_t
@@ -53,13 +54,13 @@ public:
typedef T element_type;
shared_array() BOOST_NOEXCEPT : px( 0 ), pn()
shared_array() BOOST_SP_NOEXCEPT : px( 0 ), pn()
{
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
shared_array( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT : px( 0 ), pn()
shared_array( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn()
{
}
@@ -95,11 +96,11 @@ public:
// ... except in C++0x, move disables the implicit copy
shared_array( shared_array const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
shared_array( shared_array const & r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
}
shared_array( shared_array && r ) BOOST_NOEXCEPT : px( r.px ), pn()
shared_array( shared_array && r ) BOOST_SP_NOEXCEPT : px( r.px ), pn()
{
pn.swap( r.pn );
r.px = 0;
@@ -133,7 +134,7 @@ public:
// assignment
shared_array & operator=( shared_array const & r ) BOOST_NOEXCEPT
shared_array & operator=( shared_array const & r ) BOOST_SP_NOEXCEPT
{
this_type( r ).swap( *this );
return *this;
@@ -152,7 +153,7 @@ public:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
shared_array & operator=( shared_array && r ) BOOST_NOEXCEPT
shared_array & operator=( shared_array && r ) BOOST_SP_NOEXCEPT
{
this_type( static_cast< shared_array && >( r ) ).swap( *this );
return *this;
+51 -6
View File
@@ -30,6 +30,7 @@
#include <boost/smart_ptr/detail/sp_convertible.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#if !defined(BOOST_SP_NO_ATOMIC_ACCESS)
#include <boost/smart_ptr/detail/spinlock_pool.hpp>
@@ -344,13 +345,13 @@ public:
typedef typename boost::detail::sp_element< T >::type element_type;
shared_ptr() BOOST_NOEXCEPT : px( 0 ), pn() // never throws in 1.30+
shared_ptr() BOOST_SP_NOEXCEPT : px( 0 ), pn() // never throws in 1.30+
{
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
shared_ptr( boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT : px( 0 ), pn() // never throws
shared_ptr( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn() // never throws
{
}
@@ -402,7 +403,7 @@ public:
// ... except in C++0x, move disables the implicit copy
shared_ptr( shared_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
shared_ptr( shared_ptr const & r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
}
@@ -521,7 +522,7 @@ public:
// assignment
shared_ptr & operator=( shared_ptr const & r ) BOOST_NOEXCEPT
shared_ptr & operator=( shared_ptr const & r ) BOOST_SP_NOEXCEPT
{
this_type(r).swap(*this);
return *this;
@@ -605,7 +606,7 @@ public:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
shared_ptr( shared_ptr && r ) BOOST_NOEXCEPT : px( r.px ), pn()
shared_ptr( shared_ptr && r ) BOOST_SP_NOEXCEPT : px( r.px ), pn()
{
pn.swap( r.pn );
r.px = 0;
@@ -629,7 +630,7 @@ public:
r.px = 0;
}
shared_ptr & operator=( shared_ptr && r ) BOOST_NOEXCEPT
shared_ptr & operator=( shared_ptr && r ) BOOST_SP_NOEXCEPT
{
this_type( static_cast< shared_ptr && >( r ) ).swap( *this );
return *this;
@@ -882,6 +883,50 @@ template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U>
return shared_ptr<T>( r, p );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class T, class U> shared_ptr<T> static_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT
{
(void) static_cast< T* >( static_cast< U* >( 0 ) );
typedef typename shared_ptr<T>::element_type E;
E * p = static_cast< E* >( r.get() );
return shared_ptr<T>( std::move(r), p );
}
template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT
{
(void) const_cast< T* >( static_cast< U* >( 0 ) );
typedef typename shared_ptr<T>::element_type E;
E * p = const_cast< E* >( r.get() );
return shared_ptr<T>( std::move(r), p );
}
template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT
{
(void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
typedef typename shared_ptr<T>::element_type E;
E * p = dynamic_cast< E* >( r.get() );
return p? shared_ptr<T>( std::move(r), p ): shared_ptr<T>();
}
template<class T, class U> shared_ptr<T> reinterpret_pointer_cast( shared_ptr<U> && r ) BOOST_NOEXCEPT
{
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
typedef typename shared_ptr<T>::element_type E;
E * p = reinterpret_cast< E* >( r.get() );
return shared_ptr<T>( std::move(r), p );
}
#endif // !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
// get_pointer() enables boost::mem_fn to recognize shared_ptr
template<class T> inline typename shared_ptr<T>::element_type * get_pointer(shared_ptr<T> const & p) BOOST_NOEXCEPT
+6 -5
View File
@@ -16,6 +16,7 @@
#include <memory> // boost.TR1 include order fix
#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
namespace boost
{
@@ -31,7 +32,7 @@ public:
typedef typename boost::detail::sp_element< T >::type element_type;
weak_ptr() BOOST_NOEXCEPT : px(0), pn() // never throws in 1.30+
weak_ptr() BOOST_SP_NOEXCEPT : px(0), pn() // never throws in 1.30+
{
}
@@ -41,11 +42,11 @@ public:
// ... except in C++0x, move disables the implicit copy
weak_ptr( weak_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
weak_ptr( weak_ptr const & r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
}
weak_ptr & operator=( weak_ptr const & r ) BOOST_NOEXCEPT
weak_ptr & operator=( weak_ptr const & r ) BOOST_SP_NOEXCEPT
{
px = r.px;
pn = r.pn;
@@ -106,13 +107,13 @@ public:
// for better efficiency in the T == Y case
weak_ptr( weak_ptr && r )
BOOST_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
BOOST_SP_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
{
r.px = 0;
}
// for better efficiency in the T == Y case
weak_ptr & operator=( weak_ptr && r ) BOOST_NOEXCEPT
weak_ptr & operator=( weak_ptr && r ) BOOST_SP_NOEXCEPT
{
this_type( static_cast< weak_ptr && >( r ) ).swap( *this );
return *this;
+4
View File
@@ -34,8 +34,10 @@ import testing ;
[ run auto_ptr_rv_test.cpp ]
[ run shared_ptr_alias_test.cpp ]
[ run shared_ptr_rv_test.cpp ]
[ run shared_ptr_rv_pointer_cast_test.cpp ]
[ run shared_ptr_move_test.cpp ]
[ run shared_ptr_alias_move_test.cpp ]
[ run shared_ptr_reinterpret_pointer_cast_test.cpp ]
[ compile-fail shared_ptr_pv_fail.cpp ]
[ run sp_unary_addr_test.cpp ]
[ compile-fail scoped_ptr_eq_fail.cpp ]
@@ -201,5 +203,7 @@ import testing ;
[ compile-fail pointer_cast_dy_fail.cpp ]
[ compile-fail pointer_cast_dy_fail2.cpp ]
[ compile-fail pointer_cast_dy_fail3.cpp ]
[ run sp_nothrow_test.cpp ]
;
}
+12
View File
@@ -1,3 +1,5 @@
#include <boost/config.hpp>
//
// auto_ptr_rv_test.cpp
//
@@ -8,6 +10,14 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#if defined( BOOST_NO_AUTO_PTR )
int main()
{
}
#else
#include <boost/shared_ptr.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <memory>
@@ -109,3 +119,5 @@ int main()
return boost::report_errors();
}
#endif // #if defined( BOOST_NO_AUTO_PTR )
+5
View File
@@ -15,6 +15,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/config.hpp>
#include <memory>
#include <string>
@@ -77,11 +78,15 @@ void test()
BOOST_TEST( X::instances == 0 );
#if !defined( BOOST_NO_AUTO_PTR )
{
std::auto_ptr<X> px( new X( 0 ) );
BOOST_TEST( X::instances == 1 );
}
#endif
BOOST_TEST( X::instances == 0 );
{
+7
View File
@@ -16,8 +16,11 @@
#include <boost/scoped_array.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/config.hpp>
#include <memory>
template<class T, class U> void assert_same_type( T** pt = 0, U** pu = 0 )
{
pt = pu;
@@ -58,12 +61,16 @@ int main()
assert_same_type< boost::pointer_to_other< boost::intrusive_ptr<X>, void >::type, boost::intrusive_ptr<void> >();
assert_same_type< boost::pointer_to_other< boost::intrusive_ptr<void>, Y >::type, boost::intrusive_ptr<Y> >();
#if !defined( BOOST_NO_AUTO_PTR )
// auto_ptr
assert_same_type< boost::pointer_to_other< std::auto_ptr<X>, Y >::type, std::auto_ptr<Y> >();
assert_same_type< boost::pointer_to_other< std::auto_ptr<X>, void >::type, std::auto_ptr<void> >();
assert_same_type< boost::pointer_to_other< std::auto_ptr<void>, Y >::type, std::auto_ptr<Y> >();
#endif
// raw pointer
assert_same_type< boost::pointer_to_other< X *, Y >::type, Y * >();
+5
View File
@@ -13,6 +13,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/config.hpp>
#include <memory>
#include <string>
@@ -75,11 +76,15 @@ void test()
BOOST_TEST( X::instances == 0 );
#if !defined( BOOST_NO_AUTO_PTR )
{
std::auto_ptr<X> px( new X( 0 ) );
BOOST_TEST( X::instances == 1 );
}
#endif
BOOST_TEST( X::instances == 0 );
{
@@ -0,0 +1,55 @@
//
// shared_pointer_reinterpret_pointer_cast_test.cpp
//
// Copyright (c) 2016 Chris Glover
//
// 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/detail/lightweight_test.hpp>
struct X
{};
int main()
{
{
boost::shared_ptr<char> pc;
boost::shared_ptr<int> pi = boost::reinterpret_pointer_cast<int>(pc);
BOOST_TEST(pi.get() == 0);
boost::shared_ptr<X> px = boost::reinterpret_pointer_cast<X>(pc);
BOOST_TEST(px.get() == 0);
}
{
boost::shared_ptr<int> pi(new int);
boost::shared_ptr<char> pc = boost::reinterpret_pointer_cast<char>(pi);
boost::shared_ptr<int> pi2 = boost::reinterpret_pointer_cast<int>(pc);
BOOST_TEST(pi.get() == pi2.get());
BOOST_TEST(!(pi < pi2 || pi2 < pi));
BOOST_TEST(pi.use_count() == 3);
BOOST_TEST(pc.use_count() == 3);
BOOST_TEST(pi2.use_count() == 3);
}
{
boost::shared_ptr<X> px(new X);
boost::shared_ptr<char> pc = boost::reinterpret_pointer_cast<char>(px);
boost::shared_ptr<X> px2 = boost::reinterpret_pointer_cast<X>(pc);
BOOST_TEST(px.get() == px2.get());
BOOST_TEST(!(px < px2 || px2 < px));
BOOST_TEST(px.use_count() == 3);
BOOST_TEST(pc.use_count() == 3);
BOOST_TEST(px2.use_count() == 3);
}
return boost::report_errors();
}
+106
View File
@@ -0,0 +1,106 @@
//
// shared_ptr_rv_pointer_cast_test.cpp
//
// Copyright (c) 2016 Chris Glover
//
// 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/detail/lightweight_test.hpp>
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
struct X
{};
struct Y: public X
{};
struct U
{
virtual ~U() {}
};
struct V: public U
{};
struct W : public U
{};
int main()
{
{
boost::shared_ptr<X> px(new Y);
boost::shared_ptr<Y> py1 = boost::static_pointer_cast<Y>(px);
boost::shared_ptr<Y> py2 = boost::static_pointer_cast<Y>(std::move(px));
BOOST_TEST(!px);
BOOST_TEST(px.use_count() == 0);
BOOST_TEST(py1.get() == py2.get());
BOOST_TEST(!(py1 < py2 || py2 < py1));
BOOST_TEST(py1.use_count() == 2);
BOOST_TEST(py2.use_count() == 2);
}
{
boost::shared_ptr<int const volatile> px(new int);
boost::shared_ptr<int> px2 = boost::const_pointer_cast<int>(px);
boost::shared_ptr<int> px3 = boost::const_pointer_cast<int>(std::move(px));
BOOST_TEST(!px);
BOOST_TEST(px.use_count() == 0);
BOOST_TEST(px2.get() == px3.get());
BOOST_TEST(!(px2 < px3 || px2 < px3));
BOOST_TEST(px2.use_count() == 2);
BOOST_TEST(px3.use_count() == 2);
}
{
boost::shared_ptr<char> pv(reinterpret_cast<char*>(new Y));
boost::shared_ptr<Y> py1 = boost::reinterpret_pointer_cast<Y>(pv);
boost::shared_ptr<Y> py2 = boost::reinterpret_pointer_cast<Y>(std::move(pv));
BOOST_TEST(!pv);
BOOST_TEST(pv.use_count() == 0);
BOOST_TEST(py1.get() == py2.get());
BOOST_TEST(!(py1 < py2 || py2 < py1));
BOOST_TEST(py1.use_count() == 2);
BOOST_TEST(py2.use_count() == 2);
}
#if !defined( BOOST_NO_RTTI )
{
boost::shared_ptr<U> pu(new V);
boost::shared_ptr<V> pv1 = boost::dynamic_pointer_cast<V>(pu);
boost::shared_ptr<V> pv2 = boost::dynamic_pointer_cast<V>(std::move(pu));
BOOST_TEST(!pu);
BOOST_TEST(pu.use_count() == 0);
BOOST_TEST(pv1.get() == pv2.get());
BOOST_TEST(!(pv1 < pv2 || pv2 < pv1));
BOOST_TEST(pv1.use_count() == 2);
BOOST_TEST(pv2.use_count() == 2);
}
{
boost::shared_ptr<U> pu(new V);
boost::shared_ptr<W> pw = boost::dynamic_pointer_cast<W>(std::move(pu));
BOOST_TEST(!pw);
BOOST_TEST(pu);
}
#endif // !defined( BOOST_NO_RTTI )
return boost::report_errors();
}
#else // !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
int main()
{
return 0;
}
#endif // !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
+8
View File
@@ -850,6 +850,8 @@ void weak_ptr_constructor()
void auto_ptr_constructor()
{
#if !defined( BOOST_NO_AUTO_PTR )
{
std::auto_ptr<int> p;
boost::shared_ptr<int> pi(p);
@@ -1136,6 +1138,8 @@ void auto_ptr_constructor()
BOOST_TEST(X::instances == 0);
BOOST_TEST(Y::instances == 0);
#endif // #if !defined( BOOST_NO_AUTO_PTR )
}
void test()
@@ -1420,6 +1424,8 @@ void conversion_assignment()
void auto_ptr_assignment()
{
#if !defined( BOOST_NO_AUTO_PTR )
{
boost::shared_ptr<int> p1;
@@ -1516,6 +1522,8 @@ void auto_ptr_assignment()
BOOST_TEST(X::instances == 0);
BOOST_TEST(Y::instances == 0);
}
#endif // #if !defined( BOOST_NO_AUTO_PTR )
}
void test()
+96
View File
@@ -0,0 +1,96 @@
//
// sp_nothrow_test.cpp
//
// Copyright 2016 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/config.hpp>
#if defined( BOOST_NO_CXX11_HDR_TYPE_TRAITS )
int main()
{
}
#else
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
template<class T> void test_copy()
{
BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_copy_constructible<T> ));
BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_copy_assignable<T> ));
}
template<class T> void test_move()
{
BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_move_constructible<T> ));
BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_move_assignable<T> ));
}
template<class T> void test_default()
{
BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_default_constructible<T> ));
}
template<class T> void test_destroy()
{
BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_destructible<T> ));
}
template<class T> void test_cmd()
{
test_copy<T>();
test_move<T>();
test_default<T>();
}
struct X
{
};
struct Y: public boost::enable_shared_from_this<Y>
{
};
int main()
{
test_cmd< boost::shared_ptr<X> >();
test_cmd< boost::shared_array<X> >();
test_cmd< boost::weak_ptr<X> >();
test_copy< Y >();
test_default< Y >();
test_destroy< Y >();
// test_move< Y >();
BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_move_constructible<Y> ));
#if !( defined( BOOST_MSVC ) && BOOST_MSVC == 1700 )
BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_move_assignable<Y> ));
#endif
test_default< boost::scoped_ptr<X> >();
test_default< boost::scoped_array<X> >();
test_move< boost::intrusive_ptr<X> >();
test_default< boost::intrusive_ptr<X> >();
return boost::report_errors();
}
#endif // #if defined( BOOST_NO_CXX11_HDR_TYPE_TRAITS )