Hacker News new | ask | show | jobs
by kazinator 340 days ago
What if the object is to be mutable?
1 comments

You use constinit. But this means constexpr constructor (easy with 2-phase init, not too much of a problem for singleton objects), and trivial destruction
Does that guarantee that the static object is constructed before the first execution of the block?
Yes, it will be constructed at compile time. Not everything can be constinit.