]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/g++.dg/cpp1y/pr59867.C
cpplib.h (enum c_lang): Add CLK_GNUCXX1Z, CLK_CXX1Z...
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp1y / pr59867.C
CommitLineData
9378b06e 1// PR c++/59867
e4276ba5 2// { dg-do compile { target c++14 } }
9378b06e 3
9378b06e
ESR
4using namespace std;
5
6// constant
7template<typename T, T x>
8 struct meta_value
9 {
10 typedef meta_value type;
11 typedef T value_type;
12 static const T value = x;
13 };
14
15// array
16template<typename T, T... data>
17 struct meta_array
18 {
19 typedef meta_array type;
20 typedef T item_type;
21 };
22
23// static array -> runtime array conversion utility
24template<typename T>
25 struct array_gen;
26
27template<typename T, T... xs>
28 struct array_gen<meta_array<T, xs...>>
29 {
30 static const T value[sizeof...(xs)];
31 };
32
33template<typename T, T... xs>
34 const T
35 array_gen<meta_array<T, xs...>>::value[sizeof...(xs)] = {xs...};
36
37// static string
38template<typename T, T... xs>
39 constexpr meta_array<T, xs...>
40 operator""_s()
41 {
42 static_assert(sizeof...(xs) == 3, "What's wrong with you?");
43 return meta_array<T, xs...>();
44 }
45
46int
47main()
48{
49 auto a = "123"_s;
50 const char (& xs)[3] = array_gen<decltype("123"_s)>::value;
51}