proomt

Search

Search posts, papers, and topics

design patterns

RSS
  1. 1

    Magic statics vs. std::call_once

    Function‑local "magic" statics give you thread‑safe, one‑time init for static data, but they’re limited to static storage and shared across all instances. Use `std::call_once` (or a small `lazy<T>` wrapper) when you need per‑object lazy init or when the value isn’t a static. The post shows concrete code for both approaches, explains the pitfalls of using a static inside a member function, and ske…

    Raymond Chenmicrosoft.com3 min