csegaults
Re:Best Performance of a C++ Singleton
on Sunday March 08, 2026 @01:09AM (#47294970)
Err how does the static approach suffer from thread safety issues when the initialization happens before main even runs?
I might be responding to a llm so...
Re:Best Performance of a C++ Singleton
on Sunday March 08, 2026 @12:45AM (#47294818)
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.