1 /* 2 Copyright 2014 Glen Joseph Fernandes 3 (glenjofe@gmail.com) 4 5 Distributed under the Boost Software License, Version 1.0. 6 (http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 #include <boost/config.hpp> 9 #if !defined(BOOST_NO_CXX11_SMART_PTR) 10 #include <boost/core/lightweight_test.hpp> 11 #include <boost/smart_ptr/make_unique.hpp> 12 13 class type { 14 public: 15 static unsigned instances; 16 type()17 type() { 18 if (instances == 0) { 19 throw true; 20 } 21 ++instances; 22 } 23 ~type()24 ~type() { 25 --instances; 26 } 27 28 private: 29 type(const type&); 30 type& operator=(const type&); 31 }; 32 33 unsigned type::instances = 0; 34 main()35int main() 36 { 37 BOOST_TEST(type::instances == 0); 38 try { 39 boost::make_unique<type>(); 40 BOOST_ERROR("make_unique did not throw"); 41 } catch (...) { 42 BOOST_TEST(type::instances == 0); 43 } 44 return boost::report_errors(); 45 } 46 #else main()47int main() 48 { 49 return 0; 50 } 51 #endif 52