1 // 2 // get_local_deleter_test.cpp 3 // 4 // Copyright 2002, 2017 Peter Dimov 5 // 6 // Distributed under the Boost Software License, Version 1.0. (See 7 // accompanying file LICENSE_1_0.txt or copy at 8 // http://www.boost.org/LICENSE_1_0.txt) 9 // 10 11 #include <boost/smart_ptr/local_shared_ptr.hpp> 12 #include <boost/core/lightweight_test.hpp> 13 14 struct deleter 15 { 16 int data; 17 deleterdeleter18 deleter(): data(0) 19 { 20 } 21 operator ()deleter22 void operator()(void *) 23 { 24 BOOST_TEST(data == 17041); 25 } 26 }; 27 28 struct deleter2 29 { 30 }; 31 32 struct X 33 { 34 }; 35 main()36int main() 37 { 38 { 39 boost::local_shared_ptr<X> p; 40 41 BOOST_TEST(boost::get_deleter<void>(p) == 0); 42 BOOST_TEST(boost::get_deleter<void const>(p) == 0); 43 BOOST_TEST(boost::get_deleter<int>(p) == 0); 44 BOOST_TEST(boost::get_deleter<int const>(p) == 0); 45 BOOST_TEST(boost::get_deleter<X>(p) == 0); 46 BOOST_TEST(boost::get_deleter<X const>(p) == 0); 47 BOOST_TEST(boost::get_deleter<deleter>(p) == 0); 48 BOOST_TEST(boost::get_deleter<deleter const>(p) == 0); 49 BOOST_TEST(boost::get_deleter<deleter2>(p) == 0); 50 BOOST_TEST(boost::get_deleter<deleter2 const>(p) == 0); 51 } 52 53 { 54 boost::local_shared_ptr<X> p(new X); 55 56 BOOST_TEST(boost::get_deleter<void>(p) == 0); 57 BOOST_TEST(boost::get_deleter<void const>(p) == 0); 58 BOOST_TEST(boost::get_deleter<int>(p) == 0); 59 BOOST_TEST(boost::get_deleter<int const>(p) == 0); 60 BOOST_TEST(boost::get_deleter<X>(p) == 0); 61 BOOST_TEST(boost::get_deleter<X const>(p) == 0); 62 BOOST_TEST(boost::get_deleter<deleter>(p) == 0); 63 BOOST_TEST(boost::get_deleter<deleter const>(p) == 0); 64 BOOST_TEST(boost::get_deleter<deleter2>(p) == 0); 65 BOOST_TEST(boost::get_deleter<deleter2 const>(p) == 0); 66 } 67 68 { 69 X x; 70 boost::local_shared_ptr<X> p(&x, deleter()); 71 72 BOOST_TEST(boost::get_deleter<void>(p) == 0); 73 BOOST_TEST(boost::get_deleter<void const>(p) == 0); 74 BOOST_TEST(boost::get_deleter<int>(p) == 0); 75 BOOST_TEST(boost::get_deleter<int const>(p) == 0); 76 BOOST_TEST(boost::get_deleter<X>(p) == 0); 77 BOOST_TEST(boost::get_deleter<X const>(p) == 0); 78 BOOST_TEST(boost::get_deleter<deleter2>(p) == 0); 79 BOOST_TEST(boost::get_deleter<deleter2 const>(p) == 0); 80 81 deleter * q = boost::get_deleter<deleter>(p); 82 83 BOOST_TEST(q != 0); 84 BOOST_TEST(q->data == 0); 85 86 q->data = 17041; 87 88 deleter const * r = boost::get_deleter<deleter const>(p); 89 90 BOOST_TEST(r == q); 91 BOOST_TEST(r->data == 17041); 92 } 93 94 return boost::report_errors(); 95 } 96