Mercurial > hg > CbC > CbC_gcc
annotate gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
rev | line source |
---|---|
111 | 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"); |