Std::call once Example #include <mutex> // ... static std::once_flag register_flag; std::call_once(register_flag, [this](){ this->init(); }); Favorite site cppreference std::call_once