Subject: [Boost-bugs] [Boost C++ Libraries] #7437: No hash function for enums in Boost 1.51
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-09-27 12:12:10
#7437: No hash function for enums in Boost 1.51
--------------------------------------------------------------+-------------
Reporter: Steven Barbaglia <steven.barbaglia@â¦> | Owner: danieljames
Type: Bugs | Status: new
Milestone: To Be Determined | Component: hash
Version: Boost 1.52.0 | Severity: Problem
Keywords: |
--------------------------------------------------------------+-------------
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:
{{{
#include <boost/unordered_map.hpp>
class MyClass
{
public:
enum eMyEnum
{
red,
white,
green
};
};
typedef boost::unordered_map<MyClass::eMyEnum,std::string> MyMap;
int main(int argc, char* argv[])
{
MyMap m;
MyMap::value_type v(MyClass::red,"apples");
m.insert(v);
return 0;
}
}}}
An extract from the error report is:
{{{
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<> &)'
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7437> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC