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
8 #include <string>
9 #include <iostream>
10 #include <boost/array.hpp>
11 #include <algorithm>
12 #ifndef BOOST_NO_CXX11_HDR_ARRAY
13 #include <array>
14 #endif
15
16 #ifndef BOOST_NO_CXX11_CONSTEXPR
17 constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
18 constexpr std::array<int, 10> arr_std {{ 0,1,2,3,4,5,6,7,8,9 }};
19
20 template <typename T>
sink(T t)21 void sink ( T t ) {}
22
23 template <typename T, size_t N>
sink(boost::array<T,N> & arr)24 void sink ( boost::array<T,N> &arr ) {}
25
main()26 int main()
27 {
28 // constexpr int two = arr_std.at (2);
29 constexpr int three = arr.at (3);
30 int whatever [ arr.at(4) ];
31 (void)three;
32 (void) whatever;
33 }
34
35 #else // no constexpr means no constexpr tests!
main()36 int main()
37 {
38 }
39 #endif
40