TIL the following program is legal and whatnot:
#include <vector>
struct Bar;
struct Foo
{
using BarVec = std::vector<Bar>::size_type;
};
struct Bar {};
int main()
{
Foo f;
}
How? Bar
is an incomplete type so the compiler has no way of knowing what std::vector<Bar>
is, or that it contains a member size_type
, or that the member size_type
is a type.
The only explanation I can come up with is that any hypothetical specialisation would (presumably) have to already be in scope to cause size_type
to take on a meaning different from that given in the "base" template definition, and size_type
is not a dependent name (both factors contributing to the compiler's certainty).
What's the legal rationale here?