title: How to make boost unordered_map to support flyweight<string>
body: <p>I am trying to do the following:</p>
  
  <pre><code>boost::unordered_map&lt;boost::flyweight&lt;std::string&gt;, boost::flyweight&lt;std::string&gt; &gt; map;
  
          boost::flyweight&lt;std::string&gt; foo(name);
          map[foo] = foo;
  </code></pre>
  
  <p>But the compiler complains:
  "error C2665: 'boost::hash_value' : none of the 17 overloads could convert all the argument types".</p>
  
  <p>But I have defined the following function:</p>
  
  <pre><code>std::size_t hash_value(const boost::flyweight&lt;std::string&gt; &amp; b)
  {
      boost::hash&lt;std::string&gt; hasher;
      const std::string &amp; str = b.get();
      return hasher(str);
  }
  bool operator==(const boost::flyweight&lt;std::string&gt;&amp; f, const boost::flyweight&lt;std::string&gt; &amp; second)
  {
      return f.get() == second.get();
  }
  </code></pre>
  
  <p>But it doesn´t compile.</p>
  
  <p>What do I need to do to make boost unordered_map to support flyweight?</p>
  
  <p>[EDIT]
  I got it to work with the following code:</p>
  
  <pre><code>    struct flyweight_hash
      {
          std::size_t operator()(const boost::flyweight&lt;std::string&gt; &amp;elm) const
          {
              boost::hash&lt;std::string&gt; hasher;
              const std::string &amp; str = elm.get();
              return hasher(str);
          }
      };
  </code></pre>
  
  <p>and passed it as a template parameter to the construction of the map:</p>
  
  <pre><code>boost::unordered_map&lt;boost::flyweight&lt;std::string&gt;, boost::flyweight&lt;std::string&gt; , flyweight_hash &gt; map;
  </code></pre>
  
  <p>In this case I don´t understand way overloading hash_value didn´t worked.</p>