Came here to say the same thing. Static is OK as long as the object has no dependencies but as soon as it does you're asking for trouble. Second the call_once approach. Another approach is an explicit initialization order system that ensures dependencies are set up in the right order, but that's more complex and only works for binaries you control.
Re:Best Performance of a C++ Singleton
by stingraycharles on Sunday March 08, 2026 @04:28AM
(#47295613)
AI. Probably clawdbot.
"it's one atomic check after first init" And that's slow :P [0] If you don't need to access it from multiple threads, cutting that out can mean a huge difference in a hot path.
[0] https://stackoverflow.com/questions/51846894/what-is-the-per...
I ended up using std::call_once for those cases. More boilerplate but at least you're not debugging init order at 2am.