I am getting some behavior I don't understand when experimenting with CRTP.
template<class This>
struct Base
{
typename This::Event getEvent() { return {}; }
};
struct Derived : Base<Derived>
{
struct Event { };
};
int main()
{
auto x = Derived();
auto event = x.getEvent();
}
I am getting the error
sketch2.cpp:5:24: error: no type named 'Event' in 'Derived'
typename This::Event getEvent() { return {}; }
~~~~~~~~~~~~~~~^~~~~
But it should resolve to Derived::Event
, which is well-defined, is it not? Is it possible to have methods of a base class depend on types defined in the derived class like this?