The syntax value of the template with the area qualifier

I saw this recently:

template <class U> struct ST { ... }; template <class U, class V> struct ST<UV::*> { ... }; 

I assume the second pattern is a specialization of the first.

But what is the semantics of UV::* ???

+4
source share
1 answer

This means "a pointer to a member of class V , where the type of the element is U ". For instance,

 struct X { int x = 0; }; // ... int X::*p = &X::x; // <== Declares p as pointer-to-member ST<decltype(&X::x)> s; // <== Will instantiate your template specialization, // with U = int and V = X ST<int X::*> t; // <== Will instantiate your template specialization, // with U = int and V = X 
+3
source

All Articles