2 Copyright 2014 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #include <boost/config.hpp>
9 #if !defined(BOOST_NO_CXX11_SMART_PTR)
10 #include <boost/detail/lightweight_test.hpp>
11 #include <boost/smart_ptr/make_unique.hpp>
15 static unsigned instances;
27 type& operator=(const type&);
30 unsigned type::instances = 0;
35 std::unique_ptr<int[]> result =
36 boost::make_unique_noinit<int[]>(3);
37 BOOST_TEST(result.get() != 0);
40 std::unique_ptr<int[][2]> result =
41 boost::make_unique_noinit<int[][2]>(2);
42 BOOST_TEST(result.get() != 0);
44 BOOST_TEST(type::instances == 0);
46 std::unique_ptr<type[]> result =
47 boost::make_unique_noinit<type[]>(3);
48 BOOST_TEST(result.get() != 0);
49 BOOST_TEST(type::instances == 3);
51 BOOST_TEST(type::instances == 0);
53 BOOST_TEST(type::instances == 0);
55 std::unique_ptr<type[][2]> result =
56 boost::make_unique_noinit<type[][2]>(2);
57 BOOST_TEST(result.get() != 0);
58 BOOST_TEST(type::instances == 4);
60 BOOST_TEST(type::instances == 0);
62 BOOST_TEST(type::instances == 0);
64 std::unique_ptr<const type[]> result =
65 boost::make_unique_noinit<const type[]>(3);
66 BOOST_TEST(result.get() != 0);
67 BOOST_TEST(type::instances == 3);
69 BOOST_TEST(type::instances == 0);
71 BOOST_TEST(type::instances == 0);
73 std::unique_ptr<const type[][2]> result =
74 boost::make_unique_noinit<const type[][2]>(2);
75 BOOST_TEST(result.get() != 0);
76 BOOST_TEST(type::instances == 4);
78 BOOST_TEST(type::instances == 0);
80 return boost::report_errors();