Is this usage of the Curiously Recurring Template Pattern legal?
Can I call a derived member function from a base class constructor like this?
My output is "Derived".Code:#include <cstdio> using std::printf; template <typename T> class Base { public: Base() { static_cast<T*>(this)->echo(); } void echo() { printf("Base"); } }; class Derived: public Base<Derived> { public: void echo() { printf("Derived"); } }; int main() { Derived derived; }