| 1 |
// PR c++/93867 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
template <typename CharT, unsigned N> |
| 5 |
struct basic_fixed_string |
| 6 |
{ |
| 7 |
constexpr basic_fixed_string(const CharT *p) { |
| 8 |
for (int i = 0; i < N; ++i) { |
| 9 |
m_data[i] = p[i]; |
| 10 |
} |
| 11 |
} |
| 12 |
|
| 13 |
CharT m_data[N] {}; |
| 14 |
}; |
| 15 |
|
| 16 |
template <typename CharT, unsigned N> |
| 17 |
basic_fixed_string(const CharT (&)[N]) -> basic_fixed_string<CharT,N>; |
| 18 |
|
| 19 |
template <unsigned N> |
| 20 |
using fixed_string = basic_fixed_string<char, N>; |
| 21 |
|
| 22 |
template <fixed_string path> |
| 23 |
constexpr int foo() |
| 24 |
{ |
| 25 |
return 42; |
| 26 |
} |
| 27 |
|
| 28 |
int main(int argc, char const *argv[]) |
| 29 |
{ |
| 30 |
foo<"hello">(); |
| 31 |
return 0; |
| 32 |
} |