/* Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) */ #include #include #include class type { public: type() { if (count == 4) { throw true; } ++count; } ~type() { --count; } static int count; private: type(const type&); type& operator=(const type&); }; int type::count = 0; int main() { boost::default_allocator a; type* p = a.allocate(5); try { boost::alloc_construct_n(a, p, 5); BOOST_ERROR("construct_n did not throw"); } catch (...) { BOOST_TEST_EQ(type::count, 0); } a.deallocate(p, 5); return boost::report_errors(); }