array_constexpr.cpp 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* tests using constexpr on boost:array
  2. * (C) Copyright Marshall Clow 2012
  3. * Distributed under the Boost Software License, Version 1.0. (See
  4. * accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #include <string>
  8. #include <iostream>
  9. #include <boost/array.hpp>
  10. #include <algorithm>
  11. #ifndef BOOST_NO_CXX11_HDR_ARRAY
  12. #include <array>
  13. #endif
  14. #ifndef BOOST_NO_CXX11_CONSTEXPR
  15. constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
  16. constexpr std::array<int, 10> arr_std {{ 0,1,2,3,4,5,6,7,8,9 }};
  17. template <typename T>
  18. void sink ( T t ) {}
  19. template <typename T, size_t N>
  20. void sink ( boost::array<T,N> &arr ) {}
  21. int main()
  22. {
  23. // constexpr int two = arr_std.at (2);
  24. constexpr int three = arr.at (3);
  25. int whatever [ arr.at(4) ];
  26. (void)three;
  27. (void) whatever;
  28. }
  29. #else // no constexpr means no constexpr tests!
  30. int main()
  31. {
  32. }
  33. #endif