Debian Codegraph @

gcc/testsuite/g++.dg/ext/char8_t-overload-1.C

raw
1 // Test overloading for UTF-8 literals when -fchar8_t is not in effect.
2 // { dg-do compile }
3 // { dg-options "-std=c++17 -fno-char8_t" }
4
5 template<typename T1, typename T2>
6 struct is_same
7 { static const bool value = false; };
8
9 template<typename T>
10 struct is_same<T, T>
11 { static const bool value = true; };
12
13 int fc(char);
14 long fc(unsigned char);
15 static_assert(is_same<decltype(fc('x')), int>::value, "Error");
16 static_assert(is_same<decltype(fc(u8'x')), int>::value, "Error");
17
18 int fs(const char*);
19 long fs(const unsigned char*);
20 static_assert(is_same<decltype(fs("x")), int>::value, "Error");
21 static_assert(is_same<decltype(fs(u8"x")), int>::value, "Error");
22
23 int fr(const char(&)[2]);
24 long fr(const unsigned char(&)[2]);
25 static_assert(is_same<decltype(fr("x")), int>::value, "Error");
26 static_assert(is_same<decltype(fr(u8"x")), int>::value, "Error");