When is a C++ name "dependent"? Apparently it is not dependent when it uses a type-definition in the same scope. It is however dependent, when it uses a type definition in a nested scope of this scope. Consider the following examples:
Example A:
template <typename T>
struct some_struct
{
struct B
{
int b_;
};
T some_member_func();
T a_;
};
template <typename T>
T some_struct<T>::some_member_func()
{
using hello = B;
return a_;
}
.. compiles fine.
Example B (Nested):
template <typename T>
struct some_struct
{
struct B
{
struct C {
int c_;
};
};
T some_member_func();
T a_;
};
template <typename T>
T some_struct<T>::some_member_func()
{
using hello = B::C;
return a_;
}
..issues the following error:
<source>: In member function 'T some_struct<T>::some_member_func()':
<source>:365:19: error: need 'typename' before 'some_struct<T>::B::C' because 'some_struct<T>::B' is a dependent scope
365 | using hello = B::C;
| ^
| typename
Why is some_struct::B a dependent scope but not some_struct (example A)?