1 // 2 // sp_nothrow_test.cpp 3 // 4 // Copyright 2016 Peter Dimov 5 // 6 // Distributed under the Boost Software License, Version 1.0. 7 // See accompanying file LICENSE_1_0.txt or copy at 8 // http://www.boost.org/LICENSE_1_0.txt 9 // 10 11 #include <boost/config.hpp> 12 13 #if defined( BOOST_NO_CXX11_HDR_TYPE_TRAITS ) 14 main()15int main() 16 { 17 } 18 19 #else 20 21 #include <boost/shared_ptr.hpp> 22 #include <boost/shared_array.hpp> 23 #include <boost/weak_ptr.hpp> 24 #include <boost/enable_shared_from_this.hpp> 25 #include <boost/scoped_ptr.hpp> 26 #include <boost/scoped_array.hpp> 27 #include <boost/intrusive_ptr.hpp> 28 #include <boost/core/lightweight_test_trait.hpp> 29 #include <type_traits> 30 test_copy()31template<class T> void test_copy() 32 { 33 BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_copy_constructible<T> )); 34 BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_copy_assignable<T> )); 35 } 36 test_move()37template<class T> void test_move() 38 { 39 BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_move_constructible<T> )); 40 BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_move_assignable<T> )); 41 } 42 test_default()43template<class T> void test_default() 44 { 45 BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_default_constructible<T> )); 46 } 47 test_destroy()48template<class T> void test_destroy() 49 { 50 BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_destructible<T> )); 51 } 52 test_cmd()53template<class T> void test_cmd() 54 { 55 test_copy<T>(); 56 test_move<T>(); 57 test_default<T>(); 58 } 59 60 struct X 61 { 62 }; 63 64 struct Y: public boost::enable_shared_from_this<Y> 65 { 66 }; 67 main()68int main() 69 { 70 test_cmd< boost::shared_ptr<X> >(); 71 test_cmd< boost::shared_array<X> >(); 72 test_cmd< boost::weak_ptr<X> >(); 73 74 test_copy< Y >(); 75 test_default< Y >(); 76 test_destroy< Y >(); 77 78 // test_move< Y >(); 79 BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_move_constructible<Y> )); 80 81 #if !( defined( BOOST_MSVC ) && BOOST_MSVC == 1700 ) 82 83 BOOST_TEST_TRAIT_TRUE(( std::is_nothrow_move_assignable<Y> )); 84 85 #endif 86 87 test_default< boost::scoped_ptr<X> >(); 88 test_default< boost::scoped_array<X> >(); 89 90 test_move< boost::intrusive_ptr<X> >(); 91 test_default< boost::intrusive_ptr<X> >(); 92 93 return boost::report_errors(); 94 } 95 96 #endif // #if defined( BOOST_NO_CXX11_HDR_TYPE_TRAITS ) 97