| 1 | // make_shared_array_tmp_test.cpp |
|---|---|
| 2 | // |
| 3 | // Copyright 2017 Peter Dimov |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. |
| 6 | // See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt |
| 8 | |
| 9 | #include <boost/make_shared.hpp> |
| 10 | #include <boost/core/lightweight_test.hpp> |
| 11 | |
| 12 | struct X |
| 13 | { |
| 14 | static int destroyed; |
| 15 | |
| 16 | ~X() |
| 17 | { |
| 18 | ++destroyed; |
| 19 | } |
| 20 | }; |
| 21 | |
| 22 | int X::destroyed = 0; |
| 23 | |
| 24 | int main() |
| 25 | { |
| 26 | { |
| 27 | X::destroyed = 0; |
| 28 | |
| 29 | boost::make_shared< X[3] >(); |
| 30 | |
| 31 | BOOST_TEST_EQ( X::destroyed, 3 ); |
| 32 | } |
| 33 | |
| 34 | { |
| 35 | X::destroyed = 0; |
| 36 | |
| 37 | boost::make_shared< X[] >( size: 3 ); |
| 38 | |
| 39 | BOOST_TEST_EQ( X::destroyed, 3 ); |
| 40 | } |
| 41 | |
| 42 | return boost::report_errors(); |
| 43 | } |
| 44 |
