title: Is it possible to use a member of a structure as a key in a map without creating a copy of key?
body: <p>Consider the following structure:</p>
  
  <pre><code>struct MyClass{
      int x;
      double y;
      std::string key;
      MyClass (int const x_, double const y_, std::string const&amp; key_) :
      x(x_), y(y_), key(key_){}   
  };
  </code></pre>
  
  <p>This is my current approach to searching a map for a <code>MyClass</code> object:</p>
  
  <pre><code>std::map&lt;std::string, MyClass&gt; myMap;
  MyClass tmp(1,2.0,"Some Key");
  myMap.insert({tmp.key,tmp}); // I now have 2 copies of the Key in the map per object MyClass
  auto itr = myMap.find("Some Key");
  </code></pre>
  
  <p>Is it possible to use the member in MyClass as the key without needing to copy the Key?</p>