Já é a segunda vez que uso este método simples para funções "once". std::atomic initialized = false; void initialize () { if (initialized.exchange(true)) return; // do initialization only once } // reentrant, safe to call from async threads void api (int foo, int bar) { initialize(); // do interesting stuff }
Artigos sobre usar software e fazer software. E, às vezes, algum apócrifo sobre hardware.