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