]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/make_unique_noinit_test.cpp
3de787c25f8de671bef94cbc8957163530da8726
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / make_unique_noinit_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_noinit<int>();
37 BOOST_TEST(a1.get() != 0);
38 }
39
40 BOOST_TEST(type::instances == 0);
41 {
42 std::unique_ptr<type> a1 = boost::make_unique_noinit<type>();
43 BOOST_TEST(a1.get() != 0);
44 BOOST_TEST(type::instances == 1);
45 a1.reset();
46 BOOST_TEST(type::instances == 0);
47 }
48
49 BOOST_TEST(type::instances == 0);
50 {
51 std::unique_ptr<const type> a1 = boost::make_unique_noinit<const type>();
52 BOOST_TEST(a1.get() != 0);
53 BOOST_TEST(type::instances == 1);
54 a1.reset();
55 BOOST_TEST(type::instances == 0);
56 }
57
58 return boost::report_errors();
59 }
60 #else
61
62 int main()
63 {
64 return 0;
65 }
66
67 #endif