From 0294dc5f4eec5a07d70fac48f75c498c3b1a339b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 19 Feb 2020 21:40:03 +0000 Subject: [PATCH] libstdc++: Simplify std::totally_ordered (LWG 3331) * include/std/concepts (__detail::__partially_ordered_with): Move here from . (totally_ordered, totally_ordered_with): Use __partially_ordered_with to simplify definition (LWG 3331). * libsupc++/compare (__detail::__partially_ordered_with): Move to . --- libstdc++-v3/ChangeLog | 7 +++++++ libstdc++-v3/include/std/concepts | 35 +++++++++++++++++-------------- libstdc++-v3/libsupc++/compare | 14 ------------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3941bcbe7ba..1711a359256 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2020-02-19 Jonathan Wakely + * include/std/concepts (__detail::__partially_ordered_with): Move here + from . + (totally_ordered, totally_ordered_with): Use __partially_ordered_with + to simplify definition (LWG 3331). + * libsupc++/compare (__detail::__partially_ordered_with): Move to + . + * include/std/concepts (totally_ordered_with): Remove redundant requirement (LWG 3329). diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts index be125c636a1..ba232e953ec 100644 --- a/libstdc++-v3/include/std/concepts +++ b/libstdc++-v3/include/std/concepts @@ -297,16 +297,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __detail::__cref<_Up>>> && __detail::__weakly_eq_cmp_with<_Tp, _Up>; + namespace __detail + { + template + concept __partially_ordered_with + = requires(const remove_reference_t<_Tp>& __t, + const remove_reference_t<_Up>& __u) { + { __t < __u } -> __boolean_testable; + { __t > __u } -> __boolean_testable; + { __t <= __u } -> __boolean_testable; + { __t >= __u } -> __boolean_testable; + { __u < __t } -> __boolean_testable; + { __u > __t } -> __boolean_testable; + { __u <= __t } -> __boolean_testable; + { __u >= __t } -> __boolean_testable; + }; + } // namespace __detail + // [concept.totallyordered], concept totally_ordered template concept totally_ordered = equality_comparable<_Tp> - && requires(__detail::__cref<_Tp> __a, __detail::__cref<_Tp> __b) { - { __a < __b } -> __detail::__boolean_testable; - { __a > __b } -> __detail::__boolean_testable; - { __a <= __b } -> __detail::__boolean_testable; - { __a >= __b } -> __detail::__boolean_testable; - }; + && __detail::__partially_ordered_with<_Tp, _Tp>; template concept totally_ordered_with @@ -314,16 +326,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && equality_comparable_with<_Tp, _Up> && totally_ordered, __detail::__cref<_Up>>> - && requires(__detail::__cref<_Tp> __t, __detail::__cref<_Up> __u) { - { __t < __u } -> __detail::__boolean_testable; - { __t > __u } -> __detail::__boolean_testable; - { __t <= __u } -> __detail::__boolean_testable; - { __t >= __u } -> __detail::__boolean_testable; - { __u < __t } -> __detail::__boolean_testable; - { __u > __t } -> __detail::__boolean_testable; - { __u <= __t } -> __detail::__boolean_testable; - { __u >= __t } -> __detail::__boolean_testable; - }; + && __detail::__partially_ordered_with<_Tp, _Up>; template concept regular = semiregular<_Tp> && equality_comparable<_Tp>; diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index ba7db316486..a74ebc845bf 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -411,20 +411,6 @@ namespace std template concept __compares_as = same_as, _Cat>; - - template - concept __partially_ordered_with - = requires(const remove_reference_t<_Tp>& __t, - const remove_reference_t<_Up>& __u) { - { __t < __u } -> __boolean_testable; - { __t > __u } -> __boolean_testable; - { __t <= __u } -> __boolean_testable; - { __t >= __u } -> __boolean_testable; - { __u < __t } -> __boolean_testable; - { __u > __t } -> __boolean_testable; - { __u <= __t } -> __boolean_testable; - { __u >= __t } -> __boolean_testable; - }; } // namespace __detail // [cmp.concept], concept three_way_comparable -- 2.30.2