title: error: assignment of read-only location <unnamed>::g_namesmap
body: <p>I am encountering the error mentioned in the title of this question. The code snippet looks like this:</p>
  
  <pre><code>namespace
  {
      struct myOptVar * g_optvar = 0;
  
      //Variable that stores map of names to index
      std::map&lt;std::string, const size_t&gt; g_namesmap;
  };
  
  void Optimizations::generate()
  {
      // free current optvar structure
      free(g_optvar);
  
      //clear our names map
      g_namesmap.clear();
  
      // create new optvar structure
      const unsigned int size = g_items.size();
      g_optvar = (struct myOptVar*)calloc(size, sizeof(struct myOptVar));
  
      //copy our data into the optvar struct
      size_t i=0;
      for (OptParamMapConstIter cit=g_items.begin(); cit != g_items.end(); cit++, i++ )
      {
          OptimizationParameter param((*cit).second);
          g_namesmap[(*cit).first] = i;  //error occurs here
  
      ...
  </code></pre>
  
  <p>g_namesmap is declared and defined in the unnamed namespace, why is it considered 'read only'?</p>