Boost C++ Libraries: Ticket #7437: No hash function for enums in Boost 1.51 https://svn.boost.org/trac10/ticket/7437 <p> Using enums as keys in maps has become problematic in Boost 1.51. The following code compiles with Microsoft Visual C++ 2010 under Boost 1.50, but not Boost 1.51: </p> <pre class="wiki">#include &lt;boost/unordered_map.hpp&gt; class MyClass { public: enum eMyEnum { red, white, green }; }; typedef boost::unordered_map&lt;MyClass::eMyEnum,std::string&gt; MyMap; int main(int argc, char* argv[]) { MyMap m; MyMap::value_type v(MyClass::red,"apples"); m.insert(v); return 0; } </pre><p> An extract from the error report is: </p> <pre class="wiki">boost\functional\hash\extensions.hpp(257): error C2665: 'boost::hash_value' : none of the 2 overloads could convert all the argument types boost\functional\hash\hash.hpp(115): could be 'size_t boost::hash_value(std::type_index)' boost\functional\hash\extensions.hpp(160): or 'size_t boost::hash_value(const std::tr1::tuple&lt;&gt; &amp;)' </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7437 Trac 1.4.3 Daniel James Thu, 27 Sep 2012 12:18:33 GMT status, version, milestone changed; resolution set https://svn.boost.org/trac10/ticket/7437#comment:1 https://svn.boost.org/trac10/ticket/7437#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.52.0</span> → <span class="trac-field-new">Boost 1.51.0</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.52.0</span> </li> </ul> <p> Thanks for the bug report. This was fixed in <a class="changeset" href="https://svn.boost.org/trac10/changeset/80292" title="Hash: merge enum support + cleanup some tests. ">[80292]</a>, which will be included in 1.52. </p> Ticket Steven Barbaglia <steven.barbaglia@…> Thu, 27 Sep 2012 12:19:56 GMT attachment set https://svn.boost.org/trac10/ticket/7437 https://svn.boost.org/trac10/ticket/7437 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">build_errors.txt</span> </li> </ul> <p> Full error report from MSVC 2010 </p> Ticket Steven Barbaglia <steven.barbaglia@…> Thu, 27 Sep 2012 12:21:53 GMT <link>https://svn.boost.org/trac10/ticket/7437#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7437#comment:2</guid> <description> <p> Great news! Thank you. </p> </description> <category>Ticket</category> </item> </channel> </rss>