title: Using a member of a type as a key in std::multiset
body: <p>I am creating my own tree-like container in C++. Here is an outline of how I imagine it's structure:</p>
  
  <pre><code>//==========================================================
  // Concept
  //==========================================================
  //
  // RootNode -&gt; Attributes
  //          -&gt; Nodes -&gt; Attributes
  //                   -&gt; Nodes -&gt; Attributes
  //                            -&gt; Nodes
  //                             
  // etc...
  //==========================================================
  </code></pre>
  
  <p>I have named the type <code>DataTree</code> for now. The header looks like this:</p>
  
  <pre><code>#pragma once
  
  #include &lt;map&gt;
  #include &lt;set&gt;
  #include &lt;string&gt;
  
  namespace LB{
      class DataTree;
      struct DataTreeComparitor{
          bool operator () (DataTree const &amp; lhs, DataTree const &amp; rhs) const;
          bool operator () (std::string const &amp; lhs, DataTree const &amp; rhs) const;
          bool operator () (DataTree const &amp; lhs, std::string  const &amp; rhs) const;
      };
      class DataTree{
      public:
          template &lt;typename Type&gt;
          Type getAttribute(std::string const &amp; name) const{
              static_cast&lt;Type&gt;(*m_attributes.find(name));
          }
  
          DataTree getChild(std::string const &amp; name) const;
  
          std::string getName(void) const;
  
      private:
          std::string m_name;
  
          std::multimap&lt;std::string, std::string&gt; m_attributes;
          std::multiset&lt;DataTree, DataTreeComparitor&gt; m_children;
      };
  }
  </code></pre>
  
  <p>I would like to find elements in the container <code>m_children</code> using an <code>std::string</code>, which <code>DataTreeComparitor</code> would compare against the result of <code>getName()</code>.</p>
  
  <p>However, when trying to call <code>find()</code> on <code>m_children</code>, I get the following error from <code>mingw32</code>:</p>
  
  <pre><code>    C:/Users/Joshua/Documents/BitBucket/LBC++/LBC++/DataTree.cpp:17:31: error: no matching function for call to 'std::multiset&lt;LB::DataTree, LB::DataTreeComparitor&gt;::find(const string&amp;) const'
  </code></pre>
  
  <p>And this using <code>MSVC</code>:</p>
  
  <pre><code>    2   IntelliSense: no instance of overloaded function "std::multiset&lt;_Kty, _Pr, _Alloc&gt;::find [with _Kty=LB::DataTree, _Pr=LB::DataTreeComparitor, _Alloc=std::allocator&lt;LB::DataTree&gt;]" matches the argument list
              argument types are: (const std::string)
              object type is: const std::multiset&lt;LB::DataTree, LB::DataTreeComparitor, std::allocator&lt;LB::DataTree&gt;&gt; c:\Users\Joshua\Documents\Visual Studio 2013\Projects\Project1\Project1\Source.cpp  46  21  Project1
  </code></pre>
  
  <p>Here is the implementation, with the problem line indicated through a comment:</p>
  
  <pre><code>#include "DataTree.h"
  
  namespace LB{
      bool DataTreeComparitor::operator () (DataTree const &amp; lhs, DataTree const &amp; rhs) const{
          return lhs.getName() &lt; rhs.getName();
      }
  
      bool DataTreeComparitor::operator () (std::string const &amp; lhs, DataTree const &amp; rhs) const{
          return lhs &lt; rhs.getName();
      }
  
      bool DataTreeComparitor::operator () (DataTree const &amp; lhs, std::string  const &amp; rhs) const{
          return lhs.getName() &lt; rhs;
      }
  
      DataTree DataTree::getChild(std::string const &amp; name) const{
          return *m_children.find(name); // problem line
      }
  }
  </code></pre>
  
  <p>I cannot for the life of me work out why the compiler isn't using <code>DataTreeComparitor</code> to compare <code>DataTree</code> against an <code>std::string</code>.</p>
  
  <p>My question is, why isn't it doing so? As you can see, I've tried adding operator overloads to the comparitor where <code>std::string</code> is both the left hand operator and the right hand.</p>
  
  <p><strong>Note:</strong></p>
  
  <p>I know there are many essential features things missing from this <code>DataTree</code> type; it is still a work in progress.</p>