Hacker News new | ask | show | jobs
by nicolapede 2424 days ago
Curiously Recurring Template Pattern (CRTP) [0] in C++.

  class Derived : public Base<Derived>


[0] https://en.wikipedia.org/wiki/Curiously_recurring_template_p...
1 comments

That's awesome. I ran into this situation in C#, and looks like it is useful in some cases.

https://zpbappi.com/curiously-recurring-template-pattern-in-...

tl;dr: "Generally, whenever you need the derived class information in the base class, you are probably looking for CRTP."