title: Will non local constants be initialized before used by lambda executed from another thread?
body: <p>If I, in one translation unit defines constants used to access into a <code>std::map</code>, and passes a lambda which uses these constants to an object accessed in another thread, can I then be sure the constants are initialized?</p>
  <p>In the code below: an object of <code>class A</code> I instantiated in the main thread. In <code>A</code>'s constructor it registers a callback with an object. <br />
  Say this object is accessed from another thread, defined in another translation unit, and calls the callback, will the value of <code>kInsertString</code> be correctly initialized at this time, or will I get a crash caused by trying to access the map using uninitialized variables? <br />
  <strong>EDIT:</strong></p>
  <p>What if A constructor is interrupted by the other thread just after it registered the callback, so the lambda is called before constructor is finished?</p>
  <pre><code>const std::string kInsertString{&quot;MyValue&quot;};
  
  class A {
   public:
     A(Object&amp; obj) {
       obj.registerCallback([this](int n){ update(n); });
       ...
       ...
     }
  
   private:
     void update(int v) {
       values[kInsertString] = v;
     }
  
     std::map&lt;std::string, int&gt; values;
  };
  
  int main() {
      auto ptr = std::make_shared&lt;A&gt;(Object::getInstance());
  }
  </code></pre>