make_shared_array_tmp_test.cpp 708 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include <boost/make_shared.hpp>
  9. #include <boost/core/lightweight_test.hpp>
  10. struct X
  11. {
  12. static int destroyed;
  13. ~X()
  14. {
  15. ++destroyed;
  16. }
  17. };
  18. int X::destroyed = 0;
  19. int main()
  20. {
  21. {
  22. X::destroyed = 0;
  23. boost::make_shared< X[3] >();
  24. BOOST_TEST_EQ( X::destroyed, 3 );
  25. }
  26. {
  27. X::destroyed = 0;
  28. boost::make_shared< X[] >( 3 );
  29. BOOST_TEST_EQ( X::destroyed, 3 );
  30. }
  31. return boost::report_errors();
  32. }