I have a large number of subclasses which subscribe to various events such as initialization and entity deletion.
Currently I solve this by doing
class A{ static void init(); void kill(ID); }
class B{ static void init(); void kill(ID); }
class C{ static void init(); void kill(ID); }
A::init();
B::init();
C::init();
Which, with a multiline editor isn't difficult, and is trivial to read, but there's lots of room for mistakes, mostly remembering to add each new class to the invoking section, instead of the class adding itself as it would with dynamic polymorph.
How do I use static polymorphy to get this into a form resembling
//interface, with default behavior implementation
class W{ static void init(){...} void kill(ID){...} }
class A : W<A> {}
class B : W<B> { static void init(){...} }
constexpr auto w_classes = magic_classlist(A, B, ...)
w_classes::init();
With objects-methods, making a list of static_casted objects is easy.
But I need classes-functions. So to make an iterable list of classes, without manually adding them to a template, ideally by inheriting the superclass, if possible.