| 1 |
// Test specialization for UTF-8 literals when -fchar8_t is enabled. |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-std=c++17 -fchar8_t" } |
| 4 |
|
| 5 |
template<auto> struct ct { static constexpr int dm = 1; }; |
| 6 |
template<> struct ct<'x'> { static constexpr int dm = 2; }; |
| 7 |
template<> struct ct<u8'x'> { static constexpr int dm = 3; }; |
| 8 |
static_assert(ct<'x'>::dm == 2, "Error"); |
| 9 |
static_assert(ct<u8'x'>::dm == 3, "Error"); |
| 10 |
|
| 11 |
template<typename T, const T *> struct ct2 { static constexpr int dm = 4; }; |
| 12 |
template<const char *P> struct ct2<char,P> { static constexpr int dm = 5; }; |
| 13 |
template<const char8_t *P> struct ct2<char8_t,P> { static constexpr int dm = 6; }; |
| 14 |
constexpr const char s[] = "x"; |
| 15 |
constexpr const char8_t s8[] = u8"x"; |
| 16 |
static_assert(ct2<char,s>::dm == 5, "Error"); |
| 17 |
static_assert(ct2<char8_t,s8>::dm == 6, "Error"); |