The syntax of a non-type template parameter is the same
as a declaration of one of the following types:
- integral or enumeration
- pointer to object or pointer to function
- lvalue reference to object or lvalue reference to function
- pointer to member
- std::nullptr_t
Non-type template parameters that are declared as arrays are
converted to pointers, and that are declared as functions are converted
to pointers to functions. The following example demonstrates these
rules:
template<int a[4]> struct A { };
template<int f(int)> struct B { };
int i;
int g(int) { return 0;}
A<&i> x;
B<&g> y;
The type
of &i is
int
*, and the type
of &g is
int
(*)(int).
You can qualify a non-type template parameter with const or volatile.
You cannot declare a non-type template parameter as a
floating point, class, or void type.
Non-type non-reference template parameters
are not lvalues.