title: How to (deep)copy a map from a const object
body: <p>I have another problem I can't seem to solve..., or find on this site...</p>
  
  <p>I have an object (called DataObject) with a map, declared as follows:</p>
  
  <pre><code>std::map&lt;size_t, DataElement*&gt; dataElements;
  </code></pre>
  
  <p>Now i have a copy function (used in the copy constructor):</p>
  
  <pre><code>void DataObject::copy(DataObject const &amp;other) {
  
      //here some code to clean up the old data in this object...
  
      //copy all the elements:
      size = other.getSize();
      for(size_t i = 0; i &lt; size; ++i) {
              DataElement* dat = new DataElement(*other.dataElements[i]);
              dataElements[i] = dat;
      }
  
  }
  </code></pre>
  
  <p>This doesn't compile, since dataElements[i] is not possible on a const object. How do I make a deep copy of all the elements in the map that is owned by a const object?</p>
  
  <p>I know that the find() function is possible on a const map, but then how do I get to the actual object that I want to copy?</p>