Title
Why is std::hash specialized for error_code, but not error_condition?
Status
c++17
Section
[system.error.syn]
Submitter
Tim Song

Created on 2016-05-03.00:00:00 last changed 90 months ago

Messages

Date: 2016-08-05.03:33:05

Proposed resolution:

This wording is relative to N4582.

  1. Edit [system_error.syn], header <system_error> synopsis, as indicated:

    namespace std {
        // ...
    
        // 19.5.6 Hash support
        template<class T> struct hash;
        template<> struct hash<error_code>;
        template<> struct hash<error_condition>;
    
       // ...
    }
    
  2. Edit [syserr.hash] as indicated:

    template <> struct hash<error_code>;
    template <> struct hash<error_condition>;
    

    -1- The template specializations shall meet the requirements of class template hash (20.12.14).

Date: 2016-08-05.03:33:05

[ 2016-08 - Chicago ]

Thurs AM: Moved to Tentatively Ready

Date: 2016-05-03.00:00:00

Both error_code and error_condition have an operator< overload, enabling their use in associative containers without having to write a custom comparator.

However, only error_code has a std::hash specialization. So it's possible to have a set<error_code>, a set<error_condition>, an unordered_set<error_code>, but not an unordered_set<error_condition>. This seems...odd.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-08-05 03:33:05adminsetmessages: + msg8417
2016-08-05 03:33:05adminsetstatus: new -> ready
2016-05-03 17:13:53adminsetmessages: + msg8069
2016-05-03 00:00:00admincreate