title: Why can't I insert objects into a map in c++
body: <p>So i have a function that  is supposed to return a following map:<br>
   <code>map&lt;MyObj*, Datastruct&gt;</code></p>
  
  <p>While trying to insert object from a list which contains said objects:  </p>
  
  <pre><code>for(auto element: myList){  
      Datastruct str;  
      str.property1 = element.property1;  
      str.property2 = element.property2;  
      saidMap.insert(element.PointerToMyObj, str);  
  }
  </code></pre>
  
  <p>Objects in <em>myList</em> contain a pointer to myObj and some properties i need to move from list to a map. Having executed this code in a function below:</p>
  
  <p><code>map&lt;MyObj*, Datastruct&gt; listToMap = convertList(myList);</code></p>
  
  <p>I get yelled at by the compiler that:  </p>
  
  <blockquote>
    <p>"no matching function to call to 'std::map::insert(MyObj*&amp;, Datastruct&amp;)"</p>
  </blockquote>
  
  <p>Here i am helpless. I don't know why compiler would show that i am trying to pass a reference to the function if <em>element</em> in myList(see above) contains </p>
  
  <blockquote>
    <p>MyObj *PointerToMyObj;</p>
  </blockquote>
  
  <p>which, the way i see it, is a correct type to pass to the insert function right?
  I also tried with </p>
  
  <blockquote>
    <p>std::make_pair</p>
  </blockquote>
  
  <p>whereupon compiler yells at me for trying to insert a pair into a<br>
  <code>map&lt;MyObj*, Datastruct&gt;.</code></p>
  
  <p>I am utterly lost. Could someone explain to me what i am doing wrong?</p>