]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/smart_ptr/test/make_shared_array_esft_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / make_shared_array_esft_test.cpp
CommitLineData
7c673cae 1/*
b32b8144
FG
2Copyright 2012-2015 Glen Joseph Fernandes
3(glenjofe@gmail.com)
7c673cae 4
b32b8144
FG
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7c673cae
FG
7*/
8#include <boost/core/lightweight_test.hpp>
9#include <boost/smart_ptr/enable_shared_from_this.hpp>
10#include <boost/smart_ptr/make_shared.hpp>
11
12class type
13 : public boost::enable_shared_from_this<type> {
14public:
b32b8144
FG
15 static unsigned instances;
16
17 type() {
18 ++instances;
7c673cae 19 }
b32b8144 20
7c673cae 21 ~type() {
b32b8144 22 --instances;
7c673cae 23 }
b32b8144 24
7c673cae
FG
25private:
26 type(const type&);
27 type& operator=(const type&);
28};
29
b32b8144 30unsigned type::instances = 0;
7c673cae
FG
31
32int main()
33{
34 BOOST_TEST(type::instances == 0);
35 {
b32b8144
FG
36 boost::shared_ptr<type[]> result =
37 boost::make_shared<type[]>(3);
7c673cae 38 try {
b32b8144 39 result[0].shared_from_this();
7c673cae
FG
40 BOOST_ERROR("shared_from_this did not throw");
41 } catch (...) {
42 BOOST_TEST(type::instances == 3);
43 }
44 }
45 BOOST_TEST(type::instances == 0);
46 {
b32b8144
FG
47 boost::shared_ptr<type[3]> result =
48 boost::make_shared_noinit<type[3]>();
7c673cae 49 try {
b32b8144 50 result[0].shared_from_this();
7c673cae
FG
51 BOOST_ERROR("shared_from_this did not throw");
52 } catch (...) {
53 BOOST_TEST(type::instances == 3);
54 }
55 }
56 return boost::report_errors();
57}