A template-argument for a non-type, non-template template-parameter shall be one of:
— an integral constant expression; or
— the name of a non-type template-parameter; or
— the address of an object or function with external linkage, including function templates and function template-ids but excluding non-static class members, expressed as & id-expression where the & is optional if the name refers to a function or array, or if the corresponding template-parameter is a reference; or
— a constant expression that evaluates to a null pointer value (4.10); or
— a constant expression that evaluates to a null member pointer value (4.11); or
— a pointer to member expressed as described in 5.3.1.
[ Note: A string literal (2.13.4) does not satisfy the requirements of any of these categories and thus is not an acceptable
template-argument. [ Example:
1 2 3 4 5 6 7
| template<class T, char* p> class X {
X();
X(const char* q) { /* ... */ }
};
X<int, "Studebaker"> x1; // error: string literal as template-argument
char p[] = "Vivisectionist";
X<int,p> x2; // OK |
—end example ] —end note ]
Partager