vendredi 3 mars 2017

Automatic registration of derived classes with C++11

As other users I'm trying to achieve something impossible or very complicated. I read many questions, like "iterating all derived classes", but as I see, it's impossible. But I want to ask is possible to make registration of derived classes automatically. Maybe with using some templates. Or for example use template function with special name (for example template<typename T> void register(SomeFabric* f, T* t = new T())) and iterate through all 'registed' types (if it's possible, ofc). Or use another special function (for example void register(SomeFabric* f, Base* base)) and iterate through all available classes and if this special function can be called with this arguments and if iteratable class can be instantiated - call it. If it's totaly impossible: what's the easiest (lowest number of developer actions) way to register class?

Aucun commentaire:

Enregistrer un commentaire