The following code does not compiles using clang 3.0, is this because I have done it wrongly? Because it is not allowed in c++11 or because it is not supported in clang?
template<int OFFSET>
struct A {
enum O { offset = OFFSET };
};
template < template <int T> class Head, typename... Tail>
struct C : public Head<1>, private C<Tail> { };
int main()
{
C< A, A > c1;
return 0;
}
Compiler error:
test3.cxx:99:42: error: template argument for template template parameter must be a class template or type alias template
struct C : public Head<1>, private C<Tail> { };
^
test3.cxx:103:15: error: use of class template A requires template arguments
C< A, A > c1;
^
test3.cxx:94:12: note: template is declared here
struct A {
^
2 errors generated.
Three issues:
Tailis to be a variadic list of templates, not of types. Hence it should beinstead of
and you need to explicitly expand the parameter pack with
private C<Tail...>instead ofprivate C<Tail>.And you’ll need to implement the base case, for when
Tail...is empty:(This is compiling for with Clang 3.0)
The entire piece of code now: