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 struct type { 14 int x; 15 int y; 16 }; 17 main()18int main() 19 { 20 { 21 std::unique_ptr<type> result = boost::make_unique<type>(); 22 BOOST_TEST(result.get() != 0); 23 BOOST_TEST(result->x == 0); 24 BOOST_TEST(result->y == 0); 25 } 26 { 27 std::unique_ptr<const type> result = 28 boost::make_unique<const type>(); 29 BOOST_TEST(result.get() != 0); 30 BOOST_TEST(result->x == 0); 31 BOOST_TEST(result->y == 0); 32 } 33 #if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) 34 { 35 std::unique_ptr<type> result = 36 boost::make_unique<type>({ 1, 2 }); 37 BOOST_TEST(result.get() != 0); 38 BOOST_TEST(result->x == 1); 39 BOOST_TEST(result->y == 2); 40 } 41 { 42 std::unique_ptr<const type> result = 43 boost::make_unique<const type>({ 1, 2 }); 44 BOOST_TEST(result.get() != 0); 45 BOOST_TEST(result->x == 1); 46 BOOST_TEST(result->y == 2); 47 } 48 #endif 49 return boost::report_errors(); 50 } 51 #else main()52int main() 53 { 54 return 0; 55 } 56 #endif 57