2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com>
+ Implement LWG 2686, Why is std::hash specialized for error_code,
+ but not error_condition?
+ * include/std/system_error (hash<error_condition>): Define for C++17.
+ * testsuite/20_util/hash/operators/size_t.cc (hash<error_condition>):
+ Instantiate test for error_condition.
+ * testsuite/20_util/hash/requirements/explicit_instantiation.cc
+ (hash<error_condition>): Instantiate hash<error_condition>.
+
* include/bits/c++config (_GLIBCXX17_INLINE): Define.
* include/bits/regex_constants.h (All std::regex_constants constants):
Add _GLIBCXX17_INLINE as per P0607R0.
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
-#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
-
#include <bits/functional_hash.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
// DR 1182.
/// std::hash specialization for error_code.
template<>
return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
}
};
+#endif // _GLIBCXX_COMPATIBILITY_CXX0X
+
+#if __cplusplus > 201402L
+ // DR 2686.
+ /// std::hash specialization for error_condition.
+ template<>
+ struct hash<error_condition>
+ : public __hash_base<size_t, error_condition>
+ {
+ size_t
+ operator()(const error_condition& __e) const noexcept
+ {
+ const size_t __tmp = std::_Hash_impl::hash(__e.value());
+ return std::_Hash_impl::__hash_combine(__e.category(), __tmp);
+ }
+ };
+#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
-#endif // _GLIBCXX_COMPATIBILITY_CXX0X
-
#endif // C++11
#endif // _GLIBCXX_SYSTEM_ERROR
template class std::hash<void*>;
template class std::hash<std::string>;
template class std::hash<std::error_code>;
+#if __cplusplus > 201402L
+template class std::hash<std::error_condition>;
+#endif
#ifdef _GLIBCXX_USE_WCHAR_T
template class std::hash<wchar_t>;