aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-06-14 12:30:52 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-06-14 14:04:45 +0100
commitb76a529c095f076c4780df0c913cf6d2391bcbc9 (patch)
tree41e756b31f8630c27d74059a49559d41ce32c154
parente2c79b968ff95421c31a5a9a1b80b11321fe70d2 (diff)
downloadgcc-b76a529c095f076c4780df0c913cf6d2391bcbc9.zip
gcc-b76a529c095f076c4780df0c913cf6d2391bcbc9.tar.gz
gcc-b76a529c095f076c4780df0c913cf6d2391bcbc9.tar.bz2
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.
-rw-r--r--libstdc++-v3/libsupc++/compare14
-rw-r--r--libstdc++-v3/testsuite/18_support/comparisons/algorithms/fallback.cc2
2 files changed, 13 insertions, 3 deletions
diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
index b1f3421..dd0ec5f 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<typename _Tp, typename _Up>
+ 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<bool>;
+ };
+
class _Partial_fallback
{
template<typename _Tp, typename _Up>
@@ -821,7 +831,7 @@ namespace std
public:
template<typename _Tp, __decayed_same_as<_Tp> _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 ae45852..05e1bf7 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<S, S> );
static_assert( has_weak_order_fallback<const S, S> );
static_assert( ! has_weak_order_fallback<const S, const S> );
static_assert( has_partial_order_fallback<S, S> );
-static_assert( has_partial_order_fallback<const S, S> );
+static_assert( ! has_partial_order_fallback<const S, S> ); // LWG 3465
static_assert( ! has_partial_order_fallback<const S, const S> );