[libcxx-commits] [libcxx] [libc++] Avoid -Wzero-as-null-pointer-constant in operator<=> (PR #79465)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 25 11:38:16 PST 2024
================
@@ -30,14 +30,17 @@ class partial_ordering;
class weak_ordering;
class strong_ordering;
-template <class _Tp, class... _Args>
-inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...);
-
struct _CmpUnspecifiedParam {
- _LIBCPP_HIDE_FROM_ABI constexpr _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
-
- template <class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>>
- _CmpUnspecifiedParam(_Tp) = delete;
+ template <class _Tp, class = __enable_if_t<is_same_v<_Tp, int>>>
+ _LIBCPP_HIDE_FROM_ABI consteval _CmpUnspecifiedParam(_Tp __zero) noexcept {
----------------
cor3ntin wrote:
Hum apparently projects like the Catch2 testing framework do try to detect the literal 0 to support fancy things such as `REQUIRE(a <=> b) == 0), so this edge case, sfinae might be useful.
We could do that in clang with the enable_if attribute but if there is a way applicable to GCC i was not able to find it https://godbolt.org/z/1xr9Wx38T (GCC does have a bug to add that attribute https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79459)
https://github.com/llvm/llvm-project/pull/79465
More information about the libcxx-commits
mailing list