Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#7437 closed Bugs (fixed)

No hash function for enums in Boost 1.51

Reported by: Steven Barbaglia <steven.barbaglia@…> Owned by: danieljames
Milestone: Boost 1.52.0 Component: hash
Version: Boost 1.51.0 Severity: Problem
Keywords: Cc:

Description

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<> &)'

Attachments (1)

build_errors.txt (4.7 KB) - added by Steven Barbaglia <steven.barbaglia@…> 5 years ago.
Full error report from MSVC 2010

Download all attachments as: .zip

Change History (3)

comment:1 Changed 5 years ago by danieljames

  • Milestone changed from To Be Determined to Boost 1.52.0
  • Resolution set to fixed
  • Status changed from new to closed
  • Version changed from Boost 1.52.0 to Boost 1.51.0

Thanks for the bug report. This was fixed in [80292], which will be included in 1.52.

Changed 5 years ago by Steven Barbaglia <steven.barbaglia@…>

Full error report from MSVC 2010

comment:2 Changed 5 years ago by Steven Barbaglia <steven.barbaglia@…>

Great news! Thank you.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain danieljames.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.