5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPARE_STRONG_ORDERING_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPARE_STRONG_ORDERING_HPP_
15#include "arene/base/stdlib_choice/cstdint.hpp"
16#include "arene/base/stdlib_choice/integral_constant.hpp"
26namespace strong_ordering_detail {
29class comparison_marker_helper {
36 using comp_ptr = comparison_marker_helper::internal comparison_marker_helper::*;
41using comparison_marker_type = comparison_marker_helper::comp_ptr;
56inline constexpr auto operator==(strong_ordering
const lhs, comparison_marker_type)
noexcept ->
bool {
57 return lhs == strong_ordering::equal;
63inline constexpr auto operator==(comparison_marker_type, strong_ordering
const rhs)
noexcept ->
bool {
64 return strong_ordering::equal == rhs;
70inline constexpr auto operator!=(strong_ordering
const lhs, comparison_marker_type)
noexcept ->
bool {
71 return lhs != strong_ordering::equal;
77inline constexpr auto operator!=(comparison_marker_type, strong_ordering
const rhs)
noexcept ->
bool {
78 return strong_ordering::equal != rhs;
84inline constexpr auto operator<(strong_ordering
const lhs, comparison_marker_type)
noexcept ->
bool {
86 return lhs < strong_ordering::equal;
93inline constexpr auto operator<(comparison_marker_type, strong_ordering
const rhs)
noexcept ->
bool {
94 return strong_ordering::equal < rhs;
100inline constexpr auto operator<=(strong_ordering
const lhs, comparison_marker_type)
noexcept ->
bool {
101 return lhs <= strong_ordering::equal;
107inline constexpr auto operator<=(comparison_marker_type, strong_ordering
const rhs)
noexcept ->
bool {
109 return strong_ordering::equal <= rhs;
116inline constexpr auto operator>(strong_ordering
const lhs, comparison_marker_type)
noexcept ->
bool {
117 return lhs > strong_ordering::equal;
123inline constexpr auto operator>(comparison_marker_type, strong_ordering
const rhs)
noexcept ->
bool {
125 return strong_ordering::equal > rhs;
132inline constexpr auto operator>=(strong_ordering
const lhs, comparison_marker_type)
noexcept ->
bool {
134 return lhs >= strong_ordering::equal;
141inline constexpr auto operator>=(comparison_marker_type, strong_ordering
const rhs)
noexcept ->
bool {
142 return strong_ordering::equal >= rhs;
158 if (three_way_result < 0) {
159 return strong_ordering::less;
161 if (three_way_result == 0) {
162 return strong_ordering::equal;
164 return strong_ordering::greater;
181 case strong_ordering::less:
183 case strong_ordering::equal:
185 case strong_ordering::greater:
213 case strong_ordering::less:
214 return strong_ordering::greater;
215 case strong_ordering::greater:
216 return strong_ordering::less;
217 case strong_ordering::equal:
218 return strong_ordering::equal;
237template <
typename C,
typename T,
typename U = T>
248template <
typename C,
typename T,
typename U = T>
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
#define ARENE_INVARIANT_UNREACHABLE(message)
Terminate the application if this line is ever executed. The supplied message will be output in that ...
Definition contract.hpp:170
Provides implementation of arene::base::is_transparent_comparator_for.
Definition accumulate.hpp:37
strong_ordering_detail::strong_ordering strong_ordering
The enumeration specifying the result of an ordering comparison.
Definition strong_ordering.hpp:147
constexpr bool is_invocable_r_v
Determine if a functor type is invocable with the specified return and argument types.
constexpr auto opposite_ordering(strong_ordering const ordering) noexcept -> strong_ordering
Return the opposite ordering for a strong_ordering three-way-comparison result.
Definition strong_ordering.hpp:209
constexpr auto make_strong_ordering(int const three_way_result) noexcept -> strong_ordering
Convert an integer three-way-comparison result into a strong_ordering.
Definition strong_ordering.hpp:157
constexpr auto from_strong_ordering(strong_ordering const ordering) noexcept -> int
Convert a strong_ordering into an integer three-way-comparison result.
Definition strong_ordering.hpp:177
constexpr bool is_transparent_comparator_v
Trait to determine if a given type is a transparent comparator.
std::integral_constant< bool, is_transparent_three_way_comparator_for_v< C, T, U > > is_transparent_three_way_comparator_for
Trait to determine if a given type is a transparent comparator for a given set of operands.
Definition strong_ordering.hpp:249
constexpr bool is_transparent_three_way_comparator_for_v
Trait to determine if a given type is a transparent comparator that performs a three-way comparison f...
Definition accumulate.hpp:36
::int8_t int8_t
An 8-bit signed integer type.
Definition cstdint.hpp:55