Non-Type Template Parameters

C++The syntax of a non-type template parameter is the same as a declaration of one of the following types:

Non-type template parameters that are declared as arrays or functions are converted to pointers or pointer to functions, respectively. The following example demonstrates this:

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 may 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 template parameters are not lvalues.

Related References

IBM Copyright 2003