title: Thread-safe static variables without mutexing?
body: <p>I remember reading that static variables declared inside methods is not thread-safe. (See <a href="http://www.tilander.org/aurora2/Static_initialization_in_Cpp/index.html" rel="nofollow noreferrer">What about the Meyer's singleton?</a> as mentioned by <a href="https://stackoverflow.com/questions/1052168/thread-safe-static-variables-without-mutexing/1052197#1052197">Todd Gardner</a>)</p>
  
  <pre><code>Dog* MyClass::BadMethod()
  {
    static Dog dog("Lassie");
    return &amp;dog;
  }
  </code></pre>
  
  <p>My library generates C++ code for end-users to compile as part of their application. The code it generates needs to initialize static variables in a thread-safe cross-platform manner. I'd like to use <code>boost::call_once</code> to mutex the variable initialization but then end-users are exposed to the Boost dependency.</p>
  
  <p>Is there a way for me to do this without forcing extra dependencies on end-users?</p>