From 7e4b7d7bacd750628a99a42237e75810a4359b74 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 18 Oct 2019 12:27:26 +0100 Subject: [PATCH] Implement std::ranges::less without std::less * include/bits/range_cmp.h (ranges::less::operator()): Inline the logic from std::less::operator() to remove the dependency on it. From-SVN: r277150 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/bits/range_cmp.h | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1aeeb880a69..c37bbd05eb6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2019-10-18 Jonathan Wakely + + * include/bits/range_cmp.h (ranges::less::operator()): Inline the + logic from std::less::operator() to remove the dependency on it. + 2019-10-17 Jonathan Wakely * doc/doxygen/user.cfg.in (INPUT): Add new C++17 and C++20 headers. diff --git a/libstdc++-v3/include/bits/range_cmp.h b/libstdc++-v3/include/bits/range_cmp.h index 3e5bb8847ab..a77fd5274b9 100644 --- a/libstdc++-v3/include/bits/range_cmp.h +++ b/libstdc++-v3/include/bits/range_cmp.h @@ -121,10 +121,19 @@ namespace ranges noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>())) { if constexpr (__detail::__less_builtin_ptr_cmp<_Tp, _Up>) - return std::less{}( - static_cast(std::forward<_Tp>(__t)), + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __t < __u; +#endif + auto __x = reinterpret_cast<__UINTPTR_TYPE__>( + static_cast(std::forward<_Tp>(__t))); + auto __y = reinterpret_cast<__UINTPTR_TYPE__>( static_cast(std::forward<_Up>(__u))); - return std::forward<_Tp>(__t) < std::forward<_Up>(__u); + return __x < __y; + } + else + return std::forward<_Tp>(__t) < std::forward<_Up>(__u); } using is_transparent = __is_transparent; -- 2.30.2