title: Assiging value to map from anonymous namespace throw std::bad_alloc
body: <p>Below is code through error as std::bad_alloc. I am getting error on
  line <strong>obj_[key[i]] = value[i];</strong> . please help me to fix it .</p>
  
  <pre><code> #include&lt;iostream&gt;
   #include&lt;map&gt;
    using namespace std;
  
   namespace {
           const std::string key1 = "s1";
           const std::string key2 = "s2";
  
           const std::string value1 = "v1";
           const std::string value2= "v2";
   }
  
   int main()
   {
  
           std::string key[3] = {
                   key1, key2};
            std::string value[3] = {
                    value1,value2 };
           std::map&lt;std::string,std::string&gt; obj_;
  
           for (size_t i = 0; i &lt; sizeof(key); ++i) { // here its thow std::bad_alloc
                   obj_[key[i]] = value[i];
              }
  }
  </code></pre>