Multiple ChoiceHard 45s
Construct on first use idiom
The 'construct on first use' idiom fixes the static init order fiasco by:
Options
- 1Wrapping the static in a function returning a reference to a function-local static, so it initializes on first access.
- 2Declaring every non-local static object constexpr, forcing compile-time initialization order.
- 3Using thread_local instead of static, so each thread initializes its own private instance.
- 4Placing all static objects into a single translation unit so their order is fixed by source.
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.