#5254 closed Bugs (fixed)
hash template specializations require BOOST_HAS_TR1_HASH work-around
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | Boost 1.47.0 | Component: | TR1 |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | TR1 hash mingw-gcc-4.4 msvc-8 | Cc: | jim@… |
Description
The TR1 docs show the templated hash struct being in namespace std::tr1.
But putting a hash template specialization in std::tr1 doesn't work, at least in cases where BOOST_HAS_TR1_HASH isn't defined.
This is broken for both MinGW-gcc-4.4 and MSVC-8 (VS2005).
See the attached files:
- TR1_hash_break.cpp doesn't compile for either platform.
- TR1_hash_workaround.cpp compiles for both.
MSVC-8: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
TR1_hash_break.cpp TR1_hash_break.cpp(21) : error C2888: 'boost::hash<my_key>' : symbol cannot be defined within namespace 'tr1'
MinGW gcc-4.4: TR1_hash_break.cpp:17: error: specialization of 'template<class T> struct boost::hash' in different namespace F:\boost\MinGW-32\trunk\boost/boost/tr1/functional.hpp:127: error: from definition of 'template<class T> struct boost::hash' TR1_hash_break.cpp:19: error: definition of 'size_t boost::hash<my_key>::operator()(const my_key&) const' is not in namespace enclosing 'boost::hash<my_key>'
Attachments (2)
Change History (9)
by , 12 years ago
Attachment: | TR1_hash_break.cpp added |
---|
by , 12 years ago
Attachment: | TR1_hash_workaround.cpp added |
---|
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This ticket concerns tr1/functional.hpp, not libs/math/doc/... Perhaps you typo'd the ticket #.
comment:5 by , 12 years ago
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 don't do that'' :-(
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:7 by , 12 years ago
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?
Er, forgive the old-style casts on lines 20/25. They ought to be "static_cast<std::size_t>(r)". (Didn't inspect that borrowed code closely enough.)