c++ - Schwarz Counter for a vector -
i looking @ case have global static std::vector need guarantee initialized (constructed) before static objects in assortment of translation units. when how handle come across 2 proposed solutions: have static object in global function used in place of global static object. schwarz counters my concern using schwarz counter std::vector initialized twice. this link "a useful technique ensuring global object initialized once , before first use maintain count of number of translation units using it." how work global initialized once? reasoning initialized twice. once in normal course of static initialization , once when first instance of schwarz counter initialized. on related note, initialization code in schwarz counter constructor? can think of using placement new. i can how i've implemented in past: design special "no-op" constructor, nothing, , use placement new in schwartz counter. like: class foruseasstatic { public: enum m...