From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 60B5D3848412; Wed, 11 Aug 2021 15:42:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60B5D3848412 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-8848] libstdc++: Implement LWG 3465 for std::compare_partial_order_fallback [PR101056] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 2fbb6039c5fcc7b85b048eeb748bea4753ff99cc X-Git-Newrev: 546cf317558bfb178b7cadd346bb43cb963e9ce6 Message-Id: <20210811154243.60B5D3848412@sourceware.org> Date: Wed, 11 Aug 2021 15:42:43 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:42:43 -0000 https://gcc.gnu.org/g:546cf317558bfb178b7cadd346bb43cb963e9ce6 commit r11-8848-g546cf317558bfb178b7cadd346bb43cb963e9ce6 Author: Jonathan Wakely Date: Mon Jun 14 12:30:52 2021 +0100 libstdc++: Implement LWG 3465 for std::compare_partial_order_fallback [PR101056] libstdc++-v3/ChangeLog: PR libstdc++/101056 * libsupc++/compare (compare_partial_order_fallback): Add constraint using reversed parameter order, as per LWG 3465. * testsuite/18_support/comparisons/algorithms/fallback.cc: Adjust expected result. (cherry picked from commit b76a529c095f076c4780df0c913cf6d2391bcbc9) Diff: --- libstdc++-v3/libsupc++/compare | 14 ++++++++++++-- .../18_support/comparisons/algorithms/fallback.cc | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index b1f342113f1..dd0ec5fa36d 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -806,6 +806,16 @@ namespace std } }; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3465. compare_partial_order_fallback requires F < E + template + concept __op_eq_lt_lt = __op_eq_lt<_Tp, _Up> + && requires(_Tp&& __t, _Up&& __u) + { + { static_cast<_Up&&>(__u) < static_cast<_Tp&&>(__t) } + -> convertible_to; + }; + class _Partial_fallback { template @@ -821,7 +831,7 @@ namespace std public: template _Up> - requires __partially_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up> + requires __partially_ordered<_Tp, _Up> || __op_eq_lt_lt<_Tp, _Up> constexpr partial_ordering operator()(_Tp&& __e, _Up&& __f) const noexcept(_S_noexcept<_Tp, _Up>()) @@ -829,7 +839,7 @@ namespace std if constexpr (__partially_ordered<_Tp, _Up>) return _Partial_order{}(static_cast<_Tp&&>(__e), static_cast<_Up&&>(__f)); - else // __op_eq_lt<_Tp, _Up> + else // __op_eq_lt_lt<_Tp, _Up> return static_cast<_Tp&&>(__e) == static_cast<_Up&&>(__f) ? partial_ordering::equivalent : static_cast<_Tp&&>(__e) < static_cast<_Up&&>(__f) diff --git a/libstdc++-v3/testsuite/18_support/comparisons/algorithms/fallback.cc b/libstdc++-v3/testsuite/18_support/comparisons/algorithms/fallback.cc index ae458528f17..05e1bf7775e 100644 --- a/libstdc++-v3/testsuite/18_support/comparisons/algorithms/fallback.cc +++ b/libstdc++-v3/testsuite/18_support/comparisons/algorithms/fallback.cc @@ -38,5 +38,5 @@ static_assert( has_weak_order_fallback ); static_assert( has_weak_order_fallback ); static_assert( ! has_weak_order_fallback ); static_assert( has_partial_order_fallback ); -static_assert( has_partial_order_fallback ); +static_assert( ! has_partial_order_fallback ); // LWG 3465 static_assert( ! has_partial_order_fallback );