diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr.C	Fri Oct 27 22:46:09 2017 +0900
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++11 } }
+
+template<class T>
+constexpr T do_get(T* x, int n) {
+  return x[n - 1];
+}
+
+template<class T, int N>
+constexpr T get(T (&x)[N]) {
+  return do_get(x, N);
+}
+
+constexpr int arr_i[] = {1};
+constexpr auto var = get(arr_i); // #2
+static_assert(var == arr_i[0], "Error");