I read STL and encounter this pattern:
template <typename S>
class F;
// specialization
template <typename T, typename U>
class F<T(U)>{};
It compiles OK, so what does T(U) mean here?
T(U) is a type-id denoting the type "function with a single parameter of type U and return type T".
However, C++ is context-sensitive and this is only parsed as type-id because lookup of U finds a type (because it names a type template parameter). If lookup of U found a non-type, then T(U) would be parsed as expression instead, in which case it would be a functional-style explicit cast which is equivalent to the C style cast (T)U.
And if both U and T would name non-types, then it would be parsed as a function call expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With