Example
template<class T> /*typename*/T::type return_type(); // okay
template<class T> void void_parameter(/*typename*/T::type); // error: variable or field 'parameter' declared void
template<class T> auto auto_parameter(/*typename*/T::type); // okay
template<class T>
struct traits {
using type = /*typename*/ T::type; // okay
};
Puzzle
- Can you add/remove required/unnecessary
typename's
template<class T>
struct traits {
using type = typename T::type;
};
template<class T>
struct s : typename T::type {};
template<class T> typename T::type f1();
template<class T> auto f2() -> typename T::type;
auto f3(auto t) -> typename decltype(t)::type;
template<class T> auto f4(typename T::type);
template<class T> bool f5(typename T::type);
template<class T> void f6(T::type);
template<class T> auto f7(T::type) -> void;
auto f8(auto t) -> typename decltype(t)::type;
Solutions
template<class T>
struct traits {
using type = T::type;
};
template<class T>
struct s : T::type {};
template<class T> T::type f1();
template<class T> auto f2() -> T::type;
auto f3(auto t) -> decltype(t)::type;
template<class T> auto f4(T::type);
template<class T> bool f5(T::type);
template<class T> void f6(typename T::type);
template<class T> auto f7(typename T::type) -> void;
auto f8(auto t) -> decltype(t)::type;