As the first refactoring, I would use a free function that calls a static function. This is not like your main method has been called many times, so you will not notice an extra call, and this makes a minimal change to the existing code.
Of course, you are not really saying what you are trying to do, only what you want to do. If what you are trying to do is get init_foos once when you start the application, use the static initialization of the object for this, rather than calling it in main. If what you are trying to do is get init_foos after all the static objects are created, then it will be harder.
By static initialization of an object, I mean something like this in a .cpp file that has access to the init_foos definition. Make it friend and init_foos private to prevent multiple calls:
struct call_init_foos { call_init_foos () { foo::init_foos(); } } call_init_foos_on_startup;
Pete kirkham
source share