1/*
2Copyright 2014 Glen Joseph Fernandes
3(glenjofe@gmail.com)
4
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7*/
8#include <boost/config.hpp>
9#if !defined(BOOST_NO_CXX11_SMART_PTR)
10#include <boost/core/lightweight_test.hpp>
11#include <boost/smart_ptr/make_unique.hpp>
12
13class type {
14public:
15 static unsigned instances;
16
17 type() {
18 if (instances == 0) {
19 throw true;
20 }
21 ++instances;
22 }
23
24 ~type() {
25 --instances;
26 }
27
28private:
29 type(const type&);
30 type& operator=(const type&);
31};
32
33unsigned type::instances = 0;
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 }
44 return boost::report_errors();
45}
46#else
47int main()
48{
49 return 0;
50}
51#endif
52

source code of boost/libs/smart_ptr/test/make_unique_throws_test.cpp