1
我试图将我的(有限)对类模板的理解扩展为具有模板模板参数的类模板。使用模板模板参数的模板构造函数的正确语法
该声明和构造函数工作正常(当然,它编译):
template < char PROTO >
class Test
{
public:
Test(void);
~Test(void);
void doIt(unsigned char* lhs, unsigned char* rhs);
};
template< char PROTO >
Test<PROTO>::Test(void)
{
}
但是,当我尝试使用模板模板参数做同样的事情,我得到这些错误(来源误差线下方):
error: missing ‘>’ to terminate the template argument list error: template argument 1 is invalid error: missing ‘>’ to terminate the template argument list error: template argument 1 is invalid error: expected initializer before ‘>’ token
template <char v> struct Char2Type {
enum { value = v };
};
template < template<char v> class Char2Type >
class Test2
{
public:
Test2(void);
~Test2(void);
void doIt(unsigned char* lhs, unsigned char* rhs);
};
template< template<char v> class Char2Type >
Test2< Char2Type<char v> >::Test2(void) //ERROR ON THIS LINE
{
}
我使用GNU克++。上面的行有什么问题?