]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/smart_ptr/test/make_unique_throws_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / smart_ptr / test / make_unique_throws_test.cpp
CommitLineData
7c673cae 1/*
b32b8144
FG
2Copyright 2014 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/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>
12
13class type {
14public:
b32b8144 15 static unsigned instances;
7c673cae 16
b32b8144 17 type() {
7c673cae
FG
18 if (instances == 0) {
19 throw true;
20 }
b32b8144 21 ++instances;
7c673cae
FG
22 }
23
24 ~type() {
b32b8144 25 --instances;
7c673cae
FG
26 }
27
28private:
29 type(const type&);
30 type& operator=(const type&);
31};
32
b32b8144 33unsigned type::instances = 0;
7c673cae
FG
34
35int main()
36{
37 BOOST_TEST(type::instances == 0);
38 try {
39 boost::make_unique<type>();
40 BOOST_ERROR("make_unique did not throw");
41 } catch (...) {
42 BOOST_TEST(type::instances == 0);
43 }
7c673cae
FG
44 return boost::report_errors();
45}
46#else
7c673cae
FG
47int main()
48{
49 return 0;
50}
7c673cae 51#endif