#include <iostream>
struct cls {
using type = double; //case 1
// typedef double type; //case 2
};
template<typename T>
void foo(typename T::type) {
std::cout<<"T::type\n";
}
int main() {
foo<cls>(22.2);
}
I believe using
and be used instead of typedef
.
In the above code I'm getting error for case 1
but not for case 2
.
error: expected nested-name-specifier before 'type'
Could someone please explain why??