Commit 0294dc5f by Jonathan Wakely

libstdc++: Simplify std::totally_ordered (LWG 3331)

	* include/std/concepts (__detail::__partially_ordered_with): Move here
	from <compare>.
	(totally_ordered, totally_ordered_with): Use __partially_ordered_with
	to simplify definition (LWG 3331).
	* libsupc++/compare (__detail::__partially_ordered_with): Move to
	<concepts>.
parent 241ed965
2020-02-19 Jonathan Wakely <jwakely@redhat.com> 2020-02-19 Jonathan Wakely <jwakely@redhat.com>
* include/std/concepts (__detail::__partially_ordered_with): Move here
from <compare>.
(totally_ordered, totally_ordered_with): Use __partially_ordered_with
to simplify definition (LWG 3331).
* libsupc++/compare (__detail::__partially_ordered_with): Move to
<concepts>.
* include/std/concepts (totally_ordered_with): Remove redundant * include/std/concepts (totally_ordered_with): Remove redundant
requirement (LWG 3329). requirement (LWG 3329).
......
...@@ -297,16 +297,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -297,16 +297,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__detail::__cref<_Up>>> __detail::__cref<_Up>>>
&& __detail::__weakly_eq_cmp_with<_Tp, _Up>; && __detail::__weakly_eq_cmp_with<_Tp, _Up>;
namespace __detail
{
template<typename _Tp, typename _Up>
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 // [concept.totallyordered], concept totally_ordered
template<typename _Tp> template<typename _Tp>
concept totally_ordered concept totally_ordered
= equality_comparable<_Tp> = equality_comparable<_Tp>
&& requires(__detail::__cref<_Tp> __a, __detail::__cref<_Tp> __b) { && __detail::__partially_ordered_with<_Tp, _Tp>;
{ __a < __b } -> __detail::__boolean_testable;
{ __a > __b } -> __detail::__boolean_testable;
{ __a <= __b } -> __detail::__boolean_testable;
{ __a >= __b } -> __detail::__boolean_testable;
};
template<typename _Tp, typename _Up> template<typename _Tp, typename _Up>
concept totally_ordered_with concept totally_ordered_with
...@@ -314,16 +326,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -314,16 +326,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
&& equality_comparable_with<_Tp, _Up> && equality_comparable_with<_Tp, _Up>
&& totally_ordered<common_reference_t<__detail::__cref<_Tp>, && totally_ordered<common_reference_t<__detail::__cref<_Tp>,
__detail::__cref<_Up>>> __detail::__cref<_Up>>>
&& requires(__detail::__cref<_Tp> __t, __detail::__cref<_Up> __u) { && __detail::__partially_ordered_with<_Tp, _Up>;
{ __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;
};
template<typename _Tp> template<typename _Tp>
concept regular = semiregular<_Tp> && equality_comparable<_Tp>; concept regular = semiregular<_Tp> && equality_comparable<_Tp>;
......
...@@ -411,20 +411,6 @@ namespace std ...@@ -411,20 +411,6 @@ namespace std
template<typename _Tp, typename _Cat> template<typename _Tp, typename _Cat>
concept __compares_as concept __compares_as
= same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>; = same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>;
template<typename _Tp, typename _Up>
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 } // namespace __detail
// [cmp.concept], concept three_way_comparable // [cmp.concept], concept three_way_comparable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment