title: What is the best way to asynchronously fill a std::map in C++?
body: <p>I'm trying to figure out the "best" way to fill a <strong>std::map</strong> in C++11 with values read from a text file. The solution for that problem should work with STL only. </p>
  
  <p>There actually is a <a href="https://stackoverflow.com/q/19125371/2852046">duplicate</a> of my question on SO since the answers drifted off-topic by targeting std::vector instead of std::map, I'm rephrasing it following <a href="https://meta.stackexchange.com/a/48113/305249">this advice</a> from meta SO in hope to get some answers to the actual question. I've spotted two approaches/ideas so far:</p>
  
  <ol>
  <li><p><strong>Use std::fill</strong>:
  As far as I understand STL does offer <a href="http://en.cppreference.com/w/cpp/experimental/parallelism/existing#fill" rel="nofollow noreferrer"><em>(experimental)</em> parallel</a> versions of fill but apparently those do not work with maps since std::fill expects arguments to meet the "ForwardIterator" requirements. </p></li>
  <li><p><strong>std::async/std:future</strong>:
  I'm actually unsure if it is a good idea or for that matter even possible to use futures with maps. Since a map is supposed to have a unique keyset and multiple futures theoretically could be added before having an actual key value. In this case will std::map stall the concurrent inserts till the future with undetermined key value has been decided?</p></li>
  </ol>
  
  <p>Is there any practice of asynchronously loading maps (with values from a text file)? Which solution is considered safe?</p>