summaryrefslogtreecommitdiffstats
path: root/Tests/CompileFeatures/cxx_variadic_templates.cpp
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-04-02 13:02:41 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-08 09:05:54 (GMT)
commit10f33eee1dfefa9e5a2ee5cf4946095bf08b19bc (patch)
tree79380831c727bb6befad287ca4ca5bdd75bb3c2d /Tests/CompileFeatures/cxx_variadic_templates.cpp
parent750dfee29c3f45020e8fcff91499a2542913b649 (diff)
downloadCMake-10f33eee1dfefa9e5a2ee5cf4946095bf08b19bc.zip
CMake-10f33eee1dfefa9e5a2ee5cf4946095bf08b19bc.tar.gz
CMake-10f33eee1dfefa9e5a2ee5cf4946095bf08b19bc.tar.bz2
Features: Add cxx_variadic_templates.
Expect cxx_variadic_templates to implement N2555. N2555 is essentially a bugfix and predates most compiler releases which aimed to experimentally support variadic templates.
Diffstat (limited to 'Tests/CompileFeatures/cxx_variadic_templates.cpp')
-rw-r--r--Tests/CompileFeatures/cxx_variadic_templates.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp
new file mode 100644
index 0000000..1d5a706
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp
@@ -0,0 +1,65 @@
+template<int I, int... Is>
+struct Interface;
+
+template<int I>
+struct Interface<I>
+{
+ static int accumulate()
+ {
+ return I;
+ }
+};
+
+template<int I, int... Is>
+struct Interface
+{
+ static int accumulate()
+ {
+ return I + Interface<Is...>::accumulate();
+ }
+};
+
+// Note: split this into a separate test if a
+// cxx_variadic_template_template_parameters feature is added.
+
+template<typename T>
+struct eval {
+ enum {
+ Matched = 0
+ };
+};
+
+template<template<typename...> class T, typename... U>
+struct eval<T<U...> > {
+ enum {
+ Matched = 1
+ };
+};
+
+template<typename...>
+struct A {
+
+};
+template<typename T>
+struct B {
+
+};
+template<typename T, typename U>
+struct C {
+
+};
+template<typename T, typename U, typename...>
+struct D {
+
+};
+
+// Note: This test assumes that a compiler supporting this feature
+// supports static_assert. Add a workaround if that does not hold.
+static_assert(eval<A<> >::Matched, "A Matches");
+static_assert(eval<A<int> >::Matched, "A Matches");
+static_assert(eval<A<int, char> >::Matched, "A Matches");
+static_assert(eval<B<int> >::Matched, "B Matches");
+static_assert(eval<C<int, char> >::Matched, "C Matches");
+static_assert(eval<D<int, char> >::Matched, "D Matches");
+static_assert(eval<D<int, char, bool> >::Matched, "D Matches");
+static_assert(eval<D<int, char, bool, double> >::Matched, "D Matches");