Boost C++ Libraries: Ticket #5254: hash template specializations require BOOST_HAS_TR1_HASH work-around https://svn.boost.org/trac10/ticket/5254 <p> The TR1 docs show the templated hash struct being in namespace std::tr1. </p> <p> But putting a hash template specialization in std::tr1 doesn't work, at least in cases where BOOST_HAS_TR1_HASH isn't defined. </p> <p> This is broken for both MinGW-gcc-4.4 and MSVC-8 (VS2005). </p> <p> See the attached files: </p> <ul><li>TR1_hash_break.cpp doesn't compile for either platform. </li><li>TR1_hash_workaround.cpp compiles for both. </li></ul><hr /> <p> MSVC-8: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86 </p> <p> Copyright (C) Microsoft Corporation. All rights reserved. </p> <p> TR1_hash_break.cpp TR1_hash_break.cpp(21) : error C2888: 'boost::hash&lt;my_key&gt;' : symbol cannot be defined within namespace 'tr1' </p> <hr /> <p> MinGW gcc-4.4: TR1_hash_break.cpp:17: error: specialization of 'template&lt;class T&gt; struct boost::hash' in different namespace F:\boost\MinGW-32\trunk\boost/boost/tr1/functional.hpp:127: error: from definition of 'template&lt;class T&gt; struct boost::hash' TR1_hash_break.cpp:19: error: definition of 'size_t boost::hash&lt;my_key&gt;::operator()(const my_key&amp;) const' is not in namespace enclosing 'boost::hash&lt;my_key&gt;' </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5254 Trac 1.4.3 Jim Bell <jim@…> Wed, 02 Mar 2011 13:37:46 GMT attachment set https://svn.boost.org/trac10/ticket/5254 https://svn.boost.org/trac10/ticket/5254 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">TR1_hash_break.cpp</span> </li> </ul> Ticket Jim Bell <jim@…> Wed, 02 Mar 2011 13:37:57 GMT attachment set https://svn.boost.org/trac10/ticket/5254 https://svn.boost.org/trac10/ticket/5254 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">TR1_hash_workaround.cpp</span> </li> </ul> Ticket Jim Bell <jim@…> Wed, 02 Mar 2011 13:52:10 GMT <link>https://svn.boost.org/trac10/ticket/5254#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5254#comment:1</guid> <description> <p> Er, forgive the old-style casts on lines 20/25. They ought to be "static_cast&lt;std::size_t&gt;(r)". (Didn't inspect that borrowed code closely enough.) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 03 Mar 2011 11:04:52 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5254#comment:2 https://svn.boost.org/trac10/ticket/5254#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/69508" title="Fix typo in inverse_gausian.qbk. Fixes #5254.">[69508]</a>) Fix typo in inverse_gausian.qbk. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5254" title="#5254: Bugs: hash template specializations require BOOST_HAS_TR1_HASH work-around (closed: fixed)">#5254</a>. </p> Ticket Jim Bell <jim@…> Thu, 03 Mar 2011 12:43:19 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/5254#comment:3 https://svn.boost.org/trac10/ticket/5254#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> This ticket concerns tr1/functional.hpp, not libs/math/doc/... Perhaps you typo'd the ticket #. </p> Ticket anonymous Thu, 03 Mar 2011 16:27:36 GMT <link>https://svn.boost.org/trac10/ticket/5254#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5254#comment:4</guid> <description> <p> Grrr, serves me right for working on two at once.... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 03 Mar 2011 16:52:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5254#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5254#comment:5</guid> <description> <p> Will fix this shortly by making std::tr1::hash a thin wrapper inheriting from boost::hash, but.... your code will still break on MSVC-10 as there std::tr1::hash is actually an alias for std::hash, and there's nothing we can do at our end to fix that, other than to say <em>don't do that'' :-( </em></p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 03 Mar 2011 16:55:33 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5254#comment:6 https://svn.boost.org/trac10/ticket/5254#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/69520" title="Make std::tr1::hash a thin wrapper around boost::hash so folks can ...">[69520]</a>) Make std::tr1::hash a thin wrapper around boost::hash so folks can specialise it. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5254" title="#5254: Bugs: hash template specializations require BOOST_HAS_TR1_HASH work-around (closed: fixed)">#5254</a>. </p> Ticket Jim Bell <jim@…> Thu, 03 Mar 2011 19:55:32 GMT <link>https://svn.boost.org/trac10/ticket/5254#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5254#comment:7</guid> <description> <p> I'd love to see the docs, at the point of use (i.e., doc/html/boost_tr1/subject_list.html#boost_tr1.subject_list.hash), mention these portability caveats where we know about them. Do I ask too much? </p> </description> <category>Ticket</category> </item> </channel> </rss>