Skip to content

Commit

Permalink
[libc++] LWG2148, LWG2543: Enable std::hash<Enum> in C++03 and C++11.
Browse files Browse the repository at this point in the history
Fixes #49601.

Differential Revision: https://reviews.llvm.org/D119891
  • Loading branch information
Arthur O'Dwyer committed Feb 16, 2022
1 parent 3581fd3 commit 3f3abaf
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 13 deletions.
5 changes: 1 addition & 4 deletions libcxx/include/__functional/hash.h
Expand Up @@ -781,8 +781,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double>
}
};

#if _LIBCPP_STD_VER > 11

_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _Tp, bool = is_enum<_Tp>::value>
struct _LIBCPP_TEMPLATE_VIS __enum_hash
Expand All @@ -799,7 +797,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
size_t operator()(_Tp __v) const _NOEXCEPT
{
typedef typename underlying_type<_Tp>::type type;
return hash<type>{}(static_cast<type>(__v));
return hash<type>()(static_cast<type>(__v));
}
};
template <class _Tp>
Expand All @@ -813,7 +811,6 @@ template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
{
};
#endif

#if _LIBCPP_STD_VER > 14

Expand Down
Expand Up @@ -8,12 +8,9 @@

// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS

// UNSUPPORTED: c++03, c++11

// <functional>

// make sure that we can hash enumeration values
// Not very portable
// Make sure that we can hash enumeration values.

#include "test_macros.h"

Expand Down
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: c++03

// <functional>

Expand Down
4 changes: 0 additions & 4 deletions libcxx/test/support/poisoned_hash_helper.h
Expand Up @@ -79,12 +79,8 @@ using LibraryHashTypes = TypeList<
float,
double,
long double,
#if TEST_STD_VER >= 14
// Enum types
PoisonedHashDetail::Enum,
PoisonedHashDetail::EnumClass,
#endif
// pointer types
void*,
void const*,
PoisonedHashDetail::Class*
Expand Down

0 comments on commit 3f3abaf

Please sign in to comment.