The following code fails to compile with type/value mismatch error, however I know a type is being supplied. What am I missing ?
template<typename A, typename B> struct base {}; template<typename B> struct derived : base< derived<B>::type, B > { using type = int; } int main() { derived<char> d; } error: type/value mismatch at argument 1 in template parameter list for 'template<class A, class B> struct base' struct derived : base< derived<B>::type, B > note: expected a type, got 'derived<B>::type' Why is derived<B>::type not a valid type ?
Moreover tried the following :
template<typename B> struct derived : base< typename derived<B>::type, B > { using type = int; } And got the following error :
no type name 'type' in 'struct derived<char>' Why does compiler fail to detect type ?