Let's start with the code example, because it should be easy to see what's going on:
template <typename T>
struct Base
{
using Type = int;
};
template<typename T>
struct Derived : public Base<T>
{
// error: unknown type name 'Type'
using NewType = Type;
};
int main()
{}
I would have expected Derived to find Base's Type alias. However, none of the compilers I've tried (MSVC, Clang, GCC) seem to like this code.
More surprisingly, changing Derived's inheritance to:
struct Derived : public Base<int>
fixes the problem.
Is there something I can change to allow Derived to find Base's alias?
Aucun commentaire:
Enregistrer un commentaire