[MAINTAINERS] Update email and move to DCO
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / pr59867.C
blobee468aabb2b4426556e39ea4542918cf55234f62
1 // PR c++/59867
2 // { dg-do compile { target c++14 } }
3 // { dg-options -w }
5 using namespace std;
7 // constant
8 template<typename T, T x>
9   struct meta_value
10   {
11     typedef meta_value type;
12     typedef T value_type;
13     static const T value = x;
14   };
16 // array
17 template<typename T, T... data>
18   struct meta_array
19   {
20     typedef meta_array type;
21     typedef T item_type;
22   };
24 // static array -> runtime array conversion utility
25 template<typename T>
26   struct array_gen;
28 template<typename T, T... xs>
29   struct array_gen<meta_array<T, xs...>>
30   {
31     static const T value[sizeof...(xs)];
32   };
34 template<typename T, T... xs>
35   const T
36   array_gen<meta_array<T, xs...>>::value[sizeof...(xs)] = {xs...};
38 // static string
39 template<typename T, T... xs>
40   constexpr meta_array<T, xs...>
41   operator""_s()
42   {
43     static_assert(sizeof...(xs) == 3, "What's wrong with you?");
44     return meta_array<T, xs...>();
45   }
47 int
48 main()
50   auto a = "123"_s;
51   const char (& xs)[3] = array_gen<decltype("123"_s)>::value;