]>
Commit | Line | Data |
---|---|---|
4b2e63de | 1 | // { dg-do run { target c++11 } } |
3ce4f9e4 ESR |
2 | |
3 | // Test user-defined literals. | |
4 | // Test template operator declaration and definition. | |
5 | ||
6 | #include <cassert> | |
7 | ||
8 | template<char...> | |
9 | int operator"" _abc(); | |
10 | ||
11 | template<> | |
12 | int | |
13 | operator"" _abc<>() | |
14 | { return -1; } | |
15 | ||
16 | template<> | |
17 | int | |
18 | operator"" _abc<'L','U','E'>() | |
19 | { return 42; } | |
20 | ||
21 | template<> | |
22 | int | |
23 | operator"" _abc<'6','6','6'>() | |
24 | { return 21; } | |
25 | ||
23dbc169 | 26 | void |
3ce4f9e4 ESR |
27 | test1() |
28 | { | |
29 | int i = operator"" _abc<'1','2','3'>(); | |
30 | assert(i == 45); | |
31 | int universal_meaning = operator"" _abc<'L','U','E'>(); | |
32 | assert(universal_meaning == 42); | |
33 | int b = operator"" _abc<'6','6','6'>(); | |
34 | int z = operator"" _abc<>(); | |
35 | assert(z == -1); | |
36 | int j = 123_abc; | |
37 | assert(j == i); | |
38 | int jb = 666_abc; | |
39 | assert(jb == b); | |
40 | } | |
41 | ||
42 | int | |
43 | main() | |
44 | { | |
45 | test1(); | |
46 | } | |
47 | ||
48 | template<char... Chars> | |
49 | int operator"" _abc() | |
50 | { return 42 + sizeof...(Chars); } |