Ok, this is a complicated one.
I have a C++ class template that is instanciated many times. For each of these instances I need to execute a function that register some operators. This needs to be done only once per template instance before the first object of that template instance is used (which does not mean it must be executed at instanciation which happens during compile time).
Up to date I did this manually. But it is a pain. So I would like to execute the registration function automatically.
My current idea is to call a guarded registration method in the constructor. However this requires a (small) overhead whenever an instance of the class is contructed. Since this is done very often I would like to avoid that overhead.
I also tried to use a static RAII helper member but static template class members are not constructed if they are not actively accessed so this try failed.
Is there a way to execute code on class template instanciation (by a function or maybe by a RAII helper class) without a runtime overhead?