]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.dg/cpp2a/nontype-class7.C
Implement P0732R2, class types in non-type template parameters.
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp2a / nontype-class7.C
1 // Example from P0732.
2 // { dg-do compile { target c++2a } }
3
4 namespace std {
5 using size_t = decltype(sizeof(1));
6 template <typename CharT, std::size_t N>
7 struct basic_fixed_string
8 {
9 constexpr basic_fixed_string(const CharT (&foo)[N+1])
10 : m_data()
11 {
12 for (int i = 0; i <= N; ++i)
13 m_data[i] = foo[i];
14 }
15 // auto operator<=>(const basic_fixed_string &) = default;
16 CharT m_data[N+1];
17 };
18 template <typename CharT, std::size_t N>
19 basic_fixed_string(const CharT (&str)[N])->basic_fixed_string<CharT, N-1>;
20 template <std::size_t N>
21 using fixed_string = basic_fixed_string<char, N>;
22 }
23
24 template <std::basic_fixed_string Str>
25 struct A {};
26 using hello_A = A<"hello">;