typename
suggest change-
When followed by a qualified name,
typenamespecifies that it is the name of a type. This is often required in templates, in particular, when the nested name specifier is a dependent type other than the current instantiation. In this example,std::decay<T>depends on the template parameterT, so in order to name the nested typetype, we need to prefix the entire qualified name withtypename. For more details, see Where and why do I have to put the “template” and “typename” keywords?template <class T> auto decay_copy(T&& r) -> typename std::decay<T>::type; -
Introduces a type parameter in the declaration of a template. In this context, it is interchangeable with
class.template <typename T> const T& min(const T& x, const T& y) { return y < x ? y : x; } -
Since C++17,
typenamecan also be used when declaring a template template parameter, preceding the name of the parameter, just likeclass. Before C++17 that position allowed onlyclass.template <template <class T> typename U> void f() { U<int>::do_it(); U<double>::do_it(); }