aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/udlit-template.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/cpp0x/udlit-template.C')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/cpp0x/udlit-template.C50
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/udlit-template.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/udlit-template.C
new file mode 100644
index 0000000..de21b66
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/udlit-template.C
@@ -0,0 +1,50 @@
+// { dg-do run { target c++11 } }
+
+// Test user-defined literals.
+// Test template operator declaration and definition.
+
+#include <cassert>
+
+template<char...>
+ int operator"" _abc();
+
+template<>
+ int
+ operator"" _abc<>()
+ { return -1; }
+
+template<>
+ int
+ operator"" _abc<'L','U','E'>()
+ { return 42; }
+
+template<>
+ int
+ operator"" _abc<'6','6','6'>()
+ { return 21; }
+
+int
+test1()
+{
+ int i = operator"" _abc<'1','2','3'>();
+ assert(i == 45);
+ int universal_meaning = operator"" _abc<'L','U','E'>();
+ assert(universal_meaning == 42);
+ int b = operator"" _abc<'6','6','6'>();
+ int z = operator"" _abc<>();
+ assert(z == -1);
+ int j = 123_abc;
+ assert(j == i);
+ int jb = 666_abc;
+ assert(jb == b);
+}
+
+int
+main()
+{
+ test1();
+}
+
+template<char... Chars>
+ int operator"" _abc()
+ { return 42 + sizeof...(Chars); }