mercredi 29 avril 2015

Is there a way to call an initialization function only when specific class template (specialization) is instantiated?

I'm designing a wrapper over various computational functionality. Some of the underlying backends require some init functions to be called before any other API calls are made. I could use some static variable that is initialized before main, and wrap it in some function as described here so that I can catch any errors produced during initialization.

I wonder if there is a better way to handle this. Note that there will never be an instance of the class template, as everything is either a typedef or static member.

Aucun commentaire:

Enregistrer un commentaire