| ... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
| 21 | #include <__type_traits/is_enum.h> | 21 | #include <__type_traits/is_enum.h> |
| 22 | #include <__type_traits/is_floating_point.h> | 22 | #include <__type_traits/is_floating_point.h> |
| 23 | #include <__type_traits/is_integral.h> | 23 | #include <__type_traits/is_integral.h> |
| | 24 | #include <__type_traits/is_unqualified.h> |
| 24 | #include <__type_traits/underlying_type.h> | 25 | #include <__type_traits/underlying_type.h> |
| 25 | #include <__utility/pair.h> | 26 | #include <__utility/pair.h> |
| 26 | #include <__utility/swap.h> | 27 | #include <__utility/swap.h> |
| ... | @@ -355,7 +356,8 @@ struct __hash_impl { | ... | @@ -355,7 +356,8 @@ struct __hash_impl { |
| 355 | }; | 356 | }; |
| 356 | | 357 | |
| 357 | template <class _Tp> | 358 | template <class _Tp> |
| 358 | struct __hash_impl<_Tp, __enable_if_t<is_enum<_Tp>::value> > : __unary_function<_Tp, size_t> { | 359 | struct __hash_impl<_Tp, __enable_if_t<is_enum<_Tp>::value && __is_unqualified_v<_Tp> > > |
| | 360 | : __unary_function<_Tp, size_t> { |
| 359 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { | 361 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { |
| 360 | using type = __underlying_type_t<_Tp>; | 362 | using type = __underlying_type_t<_Tp>; |
| 361 | return hash<type>()(static_cast<type>(__v)); | 363 | return hash<type>()(static_cast<type>(__v)); |
| ... | @@ -363,17 +365,21 @@ struct __hash_impl<_Tp, __enable_if_t<is_enum<_Tp>::value> > : __unary_function< | ... | @@ -363,17 +365,21 @@ struct __hash_impl<_Tp, __enable_if_t<is_enum<_Tp>::value> > : __unary_function< |
| 363 | }; | 365 | }; |
| 364 | | 366 | |
| 365 | template <class _Tp> | 367 | template <class _Tp> |
| 366 | struct __hash_impl<_Tp, __enable_if_t<is_integral<_Tp>::value && (sizeof(_Tp) <= sizeof(size_t))> > | 368 | struct __hash_impl< |
| | 369 | _Tp, |
| | 370 | __enable_if_t<is_integral<_Tp>::value && __is_unqualified_v<_Tp> && (sizeof(_Tp) <= sizeof(size_t))> > |
| 367 | : __unary_function<_Tp, size_t> { | 371 | : __unary_function<_Tp, size_t> { |
| 368 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | 372 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { return static_cast<size_t>(__v); } |
| 369 | }; | 373 | }; |
| 370 | | 374 | |
| 371 | template <class _Tp> | 375 | template <class _Tp> |
| 372 | struct __hash_impl<_Tp, __enable_if_t<is_integral<_Tp>::value && (sizeof(_Tp) > sizeof(size_t))> > | 376 | struct __hash_impl<_Tp, |
| | 377 | __enable_if_t<is_integral<_Tp>::value && __is_unqualified_v<_Tp> && (sizeof(_Tp) > sizeof(size_t))> > |
| 373 | : __scalar_hash<_Tp> {}; | 378 | : __scalar_hash<_Tp> {}; |
| 374 | | 379 | |
| 375 | template <class _Tp> | 380 | template <class _Tp> |
| 376 | struct __hash_impl<_Tp, __enable_if_t<is_floating_point<_Tp>::value> > : __scalar_hash<_Tp> { | 381 | struct __hash_impl<_Tp, __enable_if_t<is_floating_point<_Tp>::value && __is_unqualified_v<_Tp> > > |
| | 382 | : __scalar_hash<_Tp> { |
| 377 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { | 383 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { |
| 378 | // -0.0 and 0.0 should return same hash | 384 | // -0.0 and 0.0 should return same hash |
| 379 | if (__v == 0.0f) | 385 | if (__v == 0.0f) |