make_local_shared_arrays_test.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2017 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #include <boost/config.hpp>
  8. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
  9. !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
  10. !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
  11. #include <boost/core/lightweight_test.hpp>
  12. #include <boost/smart_ptr/make_local_shared.hpp>
  13. int main()
  14. {
  15. {
  16. boost::local_shared_ptr<int[][2]> result =
  17. boost::make_local_shared<int[][2]>(2, {0, 1});
  18. BOOST_TEST(result[0][0] == 0);
  19. BOOST_TEST(result[0][1] == 1);
  20. BOOST_TEST(result[1][0] == 0);
  21. BOOST_TEST(result[1][1] == 1);
  22. }
  23. {
  24. boost::local_shared_ptr<int[2][2]> result =
  25. boost::make_local_shared<int[2][2]>({0, 1});
  26. BOOST_TEST(result[0][0] == 0);
  27. BOOST_TEST(result[0][1] == 1);
  28. BOOST_TEST(result[1][0] == 0);
  29. BOOST_TEST(result[1][1] == 1);
  30. }
  31. {
  32. boost::local_shared_ptr<const int[][2]> result =
  33. boost::make_local_shared<const int[][2]>(2, {0, 1});
  34. BOOST_TEST(result[0][0] == 0);
  35. BOOST_TEST(result[0][1] == 1);
  36. BOOST_TEST(result[1][0] == 0);
  37. BOOST_TEST(result[1][1] == 1);
  38. }
  39. {
  40. boost::local_shared_ptr<const int[2][2]> result =
  41. boost::make_local_shared<const int[2][2]>({0, 1});
  42. BOOST_TEST(result[0][0] == 0);
  43. BOOST_TEST(result[0][1] == 1);
  44. BOOST_TEST(result[1][0] == 0);
  45. BOOST_TEST(result[1][1] == 1);
  46. }
  47. return boost::report_errors();
  48. }
  49. #else
  50. int main()
  51. {
  52. return 0;
  53. }
  54. #endif