Tag: initialization
4 posts
-
C++ Dynamic Initialization: When Globals and Statics Run Their Initializers
What makes a C++ initializer dynamic, when it runs relative to main, ordering within and across files, exceptions before main, local statics, and constinit.
-
std::call_once and once_flag: Thread-Safe One-Time Initialization vs static Locals
std::call_once is a C++11 function that guarantees a function executes exactly once, even when called from multiple threads.
-
C++ Initialization Order: Static Phases, Cross-TU Globals, Bases and Members
When C++ objects get initialized: zero, constant and dynamic phases, why cross-file global order is unspecified, member vs initializer-list order, and fixes.
-
C++ Copy vs Direct Initialization: Why T x = value Fails Where T x(value) Compiles
Why T x = value can fail where T x(value) compiles: copy vs direct initialization, explicit constructors, conversion operators, and auto and brace gotchas.