A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/temp.arg.nontype below:

[temp.arg.nontype]

17 Templates [temp] 17.3 Template arguments [temp.arg] 17.3.2 Template non-type arguments [temp.arg.nontype]

[Example:

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;                      

end example]

[Note: A string literal is not an acceptable template-argument. [Example:

template<class T, const char* p> class X {
  /* ... */
};

X<int, "Studebaker"> x1;        
const char p[] = "Vivisectionist";
X<int,p> x2;                    

end example] end note]

[Note: The address of an array element or non-static data member is not an acceptable template-argument. [Example:

template<int* p> class X { };

int a[10];
struct S { int m; static int s; } s;

X<&a[2]> x3;                    X<&s.m> x4;                     X<&s.s> x5;                     X<&S::s> x6;                    

end example] end note]

[Note: A temporary object is not an acceptable template-argument when the corresponding template-parameter has reference type. [Example:

template<const int& CRI> struct B { /* ... */ };

B<1> b2;                        
int c = 1;
B<c> b1;                        

end example] end note]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4