Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

const variable as non-type template parameter (VARIABLE cannot appear in a constant-expression)

Tags:

Why does this work?

char __nontype[] = "foo";
typedef TemplateClass<T, __nontype> MyClass;

But this (with a constant variable) not?

const char __nontype[] = "foo";
typedef TemplateClass<T, __nontype> MyClass;

Compiler Error:

error: ‘__nontype’ cannot appear in a constant-expression

error: template argument 2 is invalid