3 ms·
The C++ equivalent is... it just works. Static variables in a function are initialized exactly once the first time a function is entered per the language defini
by cjensen 3y ago
The C++ equivalent is... it just works. Static variables in a function are initialized exactly once the first time a function is entered per the language definition.
This is one of the many great improvements of C++11
- variadix 3y agoExcept you pay this cost (locks + codegen) even for PODs with known data at compile time.
- cjensen 3y agoNo. PODs that are initialized with no side-effects can be optimized away into compile-time initialization. E.g. if you have an integer that is static inside a function, it can just be initialized old-school.