[temp.arg.nontype] (original) (raw)
13 Templates [temp]
13.4 Template arguments [temp.arg]
13.4.3 Template non-type arguments [temp.arg.nontype]
[Note 1:
If the template-argumentis an overload set (or the address of such, including forming a pointer-to-member), the matching function is selected from the set ([over.over]).
— _end note_]
[Example 1: template<const int* pci> struct X { };int ai[10]; X<ai> xi; struct Y { };template<const Y& b> struct Z { }; Y y; Z<y> z; template<int (&pa)[5]> struct W { };int b[5]; W<b> w; void f(char);void f(int);template<void (*pf)(int)> struct A { }; A<&f> a; template<auto n> struct B { }; B<5> b1; B<'a'> b2; B<2.5> b3; B<void(0)> b4; — _end example_]
[Note 2:
[Example 2: template<class T, T p> class X { }; X<const char*, "Studebaker"> x; X<const char*, "Knope" + 1> x2; const char p[] = "Vivisectionist"; X<const char*, p> y; struct A { constexpr A(const char*) {} }; X<A, "Pyrophoricity"> z; — _end example_]
— _end note_]
[Note 3:
[Example 3: template<const int& CRI> struct B { }; B<1> b1; int c = 1; B<c> b2; struct X { int n; };struct Y { const int &r; };template<Y y> struct C { }; C<Y{X{1}.n}> c; — _end example_]
— _end note_]