5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPARE_STRONG_ORDERING_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPARE_STRONG_ORDERING_HPP_
14#include "arene/base/contracts/contract.hpp"
15#include "arene/base/stdlib_choice/cstdint.hpp"
16#include "arene/base/stdlib_choice/integral_constant.hpp"
17#include "arene/base/type_traits/is_invocable.hpp"
18#include "arene/base/type_traits/is_transparent_comparator_for.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;
44enum class strong_ordering : std::int8_t {
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;
147using strong_ordering = strong_ordering_detail::strong_ordering;
157inline constexpr auto make_strong_ordering(
int const three_way_result)
noexcept -> strong_ordering {
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;
177inline constexpr auto from_strong_ordering(strong_ordering
const ordering)
noexcept ->
int {
181 case strong_ordering::less:
183 case strong_ordering::equal:
185 case strong_ordering::greater:
190 ARENE_INVARIANT_UNREACHABLE(
"Invalid ordering");
209inline constexpr auto opposite_ordering(strong_ordering
const ordering)
noexcept -> strong_ordering {
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;
222 ARENE_INVARIANT_UNREACHABLE(
"Invalid ordering");
237template <
typename C,
typename T,
typename U = T>
238extern constexpr bool is_transparent_three_way_comparator_for_v =
248template <
typename C,
typename T,
typename U =
T>
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10