crtp

Can a Delphi generic class descend from its class argument?

I've been trying to define a generic, inheritable TSingleton class. Here's what I had in progress: TSingleton<RealClass, InheritsFrom : class> = class(InheritsFrom) strict private class var FInstance : RealClass; protected procedure InstanceInitialization;virtual; public destructor Destroy; override; class proced...

What's the use of the derived class as a template parameter?

What's the purpose of this pattern? What is it called? It looked very strange when I saw it the first time, though I have now seen it many times. template<typename Derived> struct Base { //... }; struct Example : Base<Example> { //... }; ...