Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr.C

raw
1 // { dg-do compile { target c++11 } }
2
3 template<class T>
4 constexpr T do_get(T* x, int n) {
5 return x[n - 1];
6 }
7
8 template<class T, int N>
9 constexpr T get(T (&x)[N]) {
10 return do_get(x, N);
11 }
12
13 constexpr int arr_i[] = {1};
14 constexpr auto var = get(arr_i); // #2
15 static_assert(var == arr_i[0], "Error");