C++20 introduced constinit
to avoid static initialization order fiasco.
Can constinit
waive the need for the nifty counter idiom (e.g. for initialization of std::cout
)?
Can C++20
constinit
waive the need for nifty counter idiom?
No.
Static initialisation order fiasco is only a problem with dynamic initialisation phase of static objects. Sure, if you don't do dynamic initialisation, then there is no problem, and constinit
enforces that. But that doesn't solve anything when you need dynamic initialisation.