I'm getting compilation errors when trying to call the base class constructor in derived initialization list when using a template template parameter with CRTP.
Problem can be replicated with this snippet of code:
template <template<class> class Derived, class T>
struct base
{
};
template <class T>
struct derived : public base<derived, T>
{
derived()
: base<derived, T>()
{ }
};
The offending error messsage:
bug.cpp:10:16: error: template argument for template template parameter must be a class template or type alias template
: base<derived, T>()
^
bug.cpp:10:11: error: expected class member or base class name
: base<derived, T>()
^
bug.cpp:10:11: error: expected '{' or ','
3 errors generated.
This problem only appears to happen on clang (3.4), not g++ (4.8, 4.7, 4.6). I'm compiling with -std=c++11 also.
This is the first time I've needed to use CRTP with template template parameter. Am I doing this okay and it's a problem with clang++ or not?
I've grown to trust clang++ error messages more than g++ of late!
See Question&Answers more detail:os