gcc/testsuite/g++.dg/cpp1y/constexpr-array1.C
raw| 1 | // PR c++/67104 |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | template <typename T, int N> struct array |
| 5 | { |
| 6 | constexpr T &operator[](int index) { return data[index]; } |
| 7 | constexpr T operator[](int index) const { return data[index]; } |
| 8 | T data[N]; |
| 9 | }; |
| 10 | |
| 11 | constexpr array<long unsigned, 1001> |
| 12 | make_bottle_count () |
| 13 | { |
| 14 | array<long unsigned, 1001> a{}; |
| 15 | a[65] = 1; |
| 16 | return a; |
| 17 | } |
| 18 | |
| 19 | constexpr auto bottle_count = make_bottle_count (); |
| 20 | static_assert (bottle_count[65], ""); |