]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/make_unique_test.cpp
a2c6b99d87abede04e240cead9966f42287257a5
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / make_unique_test.cpp
1 /*
2 (c) 2014 Glen Joseph Fernandes
3 <glenjofe -at- gmail.com>
4
5 Distributed under the Boost Software
6 License, Version 1.0.
7 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.hpp>
13
14 class type {
15 public:
16 static unsigned int instances;
17
18 explicit type() {
19 instances++;
20 }
21
22 ~type() {
23 instances--;
24 }
25
26 private:
27 type(const type&);
28 type& operator=(const type&);
29 };
30
31 unsigned int type::instances = 0;
32
33 int main()
34 {
35 {
36 std::unique_ptr<int> a1 = boost::make_unique<int>();
37 BOOST_TEST(a1.get() != 0);
38 BOOST_TEST(*a1 == 0);
39 }
40
41 {
42 std::unique_ptr<const int> a1 = boost::make_unique<const int>();
43 BOOST_TEST(a1.get() != 0);
44 BOOST_TEST(*a1 == 0);
45 }
46
47 BOOST_TEST(type::instances == 0);
48 {
49 std::unique_ptr<type> a1 = boost::make_unique<type>();
50 BOOST_TEST(a1.get() != 0);
51 BOOST_TEST(type::instances == 1);
52 a1.reset();
53 BOOST_TEST(type::instances == 0);
54 }
55
56 BOOST_TEST(type::instances == 0);
57 {
58 std::unique_ptr<const type> a1 = boost::make_unique<const type>();
59 BOOST_TEST(a1.get() != 0);
60 BOOST_TEST(type::instances == 1);
61 a1.reset();
62 BOOST_TEST(type::instances == 0);
63 }
64
65 return boost::report_errors();
66 }
67 #else
68
69 int main()
70 {
71 return 0;
72 }
73
74 #endif