]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | if (instances == 0) { | |
20 | throw true; | |
21 | } | |
22 | instances++; | |
23 | } | |
24 | ||
25 | ~type() { | |
26 | instances--; | |
27 | } | |
28 | ||
29 | private: | |
30 | type(const type&); | |
31 | type& operator=(const type&); | |
32 | }; | |
33 | ||
34 | unsigned int type::instances = 0; | |
35 | ||
36 | int main() | |
37 | { | |
38 | BOOST_TEST(type::instances == 0); | |
39 | try { | |
40 | boost::make_unique<type>(); | |
41 | BOOST_ERROR("make_unique did not throw"); | |
42 | } catch (...) { | |
43 | BOOST_TEST(type::instances == 0); | |
44 | } | |
45 | ||
46 | return boost::report_errors(); | |
47 | } | |
48 | #else | |
49 | ||
50 | int main() | |
51 | { | |
52 | return 0; | |
53 | } | |
54 | ||
55 | #endif |