1 /*
2  * Copyright (c) 2014 Glen Joseph Fernandes
3  * glenfe at live dot com
4  *
5  * Distributed under the Boost Software License,
6  * Version 1.0. (See accompanying file LICENSE_1_0.txt
7  * or copy at http://boost.org/LICENSE_1_0.txt)
8  */
9 #include <boost/config.hpp>
10 #if !defined(BOOST_NO_CXX11_SMART_PTR)
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/smart_ptr/make_unique_object.hpp>
13 
14 struct type {
15     int x;
16     int y;
17 };
18 
main()19 int main() {
20     {
21         std::unique_ptr<type> a1 = boost::make_unique<type>();
22         BOOST_TEST(a1.get() != 0);
23         BOOST_TEST(a1->x == 0);
24         BOOST_TEST(a1->y == 0);
25     }
26 
27     {
28         std::unique_ptr<const type> a1 = boost::make_unique<const type>();
29         BOOST_TEST(a1.get() != 0);
30         BOOST_TEST(a1->x == 0);
31         BOOST_TEST(a1->y == 0);
32     }
33 
34 #if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
35     {
36         std::unique_ptr<type> a1 = boost::make_unique<type>({ 1, 2 });
37         BOOST_TEST(a1.get() != 0);
38         BOOST_TEST(a1->x == 1);
39         BOOST_TEST(a1->y == 2);
40     }
41 
42     {
43         std::unique_ptr<const type> a1 = boost::make_unique<const type>({ 1, 2 });
44         BOOST_TEST(a1.get() != 0);
45         BOOST_TEST(a1->x == 1);
46         BOOST_TEST(a1->y == 2);
47     }
48 #endif
49 
50     return boost::report_errors();
51 }
52 #else
53 
main()54 int main() {
55     return 0;
56 }
57 
58 #endif
59