[libcxx-commits] [libcxx] 3f3abaf - [libc++] LWG2148, LWG2543: Enable std::hash<Enum> in C++03 and C++11.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 16 08:02:17 PST 2022
Author: Arthur O'Dwyer
Date: 2022-02-16T11:01:49-05:00
New Revision: 3f3abaf40ad5c732277e0d0be3c0e86b8ba49f34
URL: https://github.com/llvm/llvm-project/commit/3f3abaf40ad5c732277e0d0be3c0e86b8ba49f34
DIFF: https://github.com/llvm/llvm-project/commit/3f3abaf40ad5c732277e0d0be3c0e86b8ba49f34.diff
LOG: [libc++] LWG2148, LWG2543: Enable std::hash<Enum> in C++03 and C++11.
Fixes #49601.
Differential Revision: https://reviews.llvm.org/D119891
Added:
Modified:
libcxx/include/__functional/hash.h
libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp
libcxx/test/support/poisoned_hash_helper.h
Removed:
################################################################################
diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index 61b87617db8ff..2b3b96e534216 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -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
@@ -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>
@@ -813,7 +811,6 @@ template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
{
};
-#endif
#if _LIBCPP_STD_VER > 14
diff --git a/libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp b/libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
index 4aece56b72117..6dd14dc77496a 100644
--- a/libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
@@ -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"
diff --git a/libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp b/libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp
index 85fed02190661..94cc9d912f3a7 100644
--- a/libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03, c++11
+// UNSUPPORTED: c++03
// <functional>
diff --git a/libcxx/test/support/poisoned_hash_helper.h b/libcxx/test/support/poisoned_hash_helper.h
index 9df349656da96..a0271e4af1e44 100644
--- a/libcxx/test/support/poisoned_hash_helper.h
+++ b/libcxx/test/support/poisoned_hash_helper.h
@@ -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*
More information about the libcxx-commits
mailing list