I have the following code:
template<typename T>
struct O {
struct A {
int a;
};
struct B: A {
auto f() {
this->a += 1; // OK
a += 1; // ERROR: 'a' was not declared in this scope
}
};
};
If I try to access a
property of the base class using this
pointer, compilation works great, but otherwise compiler does produce error: 'a' was not declared in this scope
.
Why does it happen?
P.S. Looks like it does work in MSVC, but does not work in GCC and Clang.