6#ifndef SL_UTILITY_FUNCTIONAL_COMPARE_HPP
7#define SL_UTILITY_FUNCTIONAL_COMPARE_HPP
29 inline constexpr auto less = envelop<Predicate>(
30 []<
class Lhs,
class Rhs>(Lhs&& lhs, Rhs&& rhs)
noexcept(
noexcept(std::declval<Lhs>() < std::declval<Rhs>()))
32 if constexpr (std::integral<std::remove_cvref_t<Lhs>> && std::integral<std::remove_cvref_t<Rhs>>)
34 return std::cmp_less(std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));
39 requires { { lhs < rhs } -> std::convertible_to<bool>; },
40 "Operands are not usable in operator < expressions.");
42 return std::forward<Lhs>(lhs) < std::forward<Rhs>(rhs);
51 []<
class Lhs,
class Rhs>(Lhs&& lhs, Rhs&& rhs)
noexcept(
noexcept(std::declval<Lhs>() <= std::declval<Rhs>()))
53 if constexpr (std::integral<std::remove_cvref_t<Lhs>> && std::integral<std::remove_cvref_t<Rhs>>)
55 return std::cmp_less_equal(std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));
60 requires { { lhs <= rhs } -> std::convertible_to<bool>; },
61 "Operands are not usable in operator <= expressions.");
63 return std::forward<Lhs>(lhs) <= std::forward<Rhs>(rhs);
71 inline constexpr auto greater = envelop<Predicate>(
72 []<
class Lhs,
class Rhs>(Lhs&& lhs, Rhs&& rhs)
noexcept(
noexcept(std::declval<Lhs>() > std::declval<Rhs>()))
74 if constexpr (std::integral<std::remove_cvref_t<Lhs>> && std::integral<std::remove_cvref_t<Rhs>>)
76 return std::cmp_greater(std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));
81 requires { { lhs > rhs } -> std::convertible_to<bool>; },
82 "Operands are not usable in operator > expressions.");
84 return std::forward<Lhs>(lhs) > std::forward<Rhs>(rhs);
93 []<
class Lhs,
class Rhs>(Lhs&& lhs, Rhs&& rhs)
noexcept(
noexcept(std::declval<Lhs>() >= std::declval<Rhs>()))
95 if constexpr (std::integral<std::remove_cvref_t<Lhs>> && std::integral<std::remove_cvref_t<Rhs>>)
97 return std::cmp_greater_equal(std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));
102 requires { { lhs >= rhs } -> std::convertible_to<bool>; },
103 "Operands are not usable in operator >= expressions.");
105 return std::forward<Lhs>(lhs) >= std::forward<Rhs>(rhs);
113 inline constexpr auto equal = envelop<Predicate>(
114 []<
class Lhs,
class Rhs>(Lhs&& lhs, Rhs&& rhs)
noexcept(
noexcept(std::declval<Lhs>() == std::declval<Rhs>()))
116 if constexpr (std::integral<std::remove_cvref_t<Lhs>> && std::integral<std::remove_cvref_t<Rhs>>)
118 return std::cmp_equal(std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));
123 requires { { lhs == rhs } -> std::convertible_to<bool>; },
124 "Operands are not usable in operator == expressions.");
126 return std::forward<Lhs>(lhs) == std::forward<Rhs>(rhs);
135 []<
class Lhs,
class Rhs>(Lhs&& lhs, Rhs&& rhs)
noexcept(
noexcept(std::declval<Lhs>() != std::declval<Rhs>()))
137 if constexpr (std::integral<std::remove_cvref_t<Lhs>> && std::integral<std::remove_cvref_t<Rhs>>)
139 return std::cmp_not_equal(std::forward<Lhs>(lhs), std::forward<Rhs>(rhs));
144 requires { { lhs != rhs } -> std::convertible_to<bool>; },
145 "Operands are not usable in operator != expressions.");
147 return std::forward<Lhs>(lhs) != std::forward<Rhs>(rhs);
158 "Operands are not usable in operator <=> expressions.");
160 return std::forward<Lhs>(lhs) <=> std::forward<Rhs>(rhs);
Checks whether a symmetrical set of operator <=> to compare both types with each other with noexcept ...
Definition: stl_extensions.hpp:260
Checks whether a symmetrical set of operator <=> to compare both types with each other exists.
Definition: stl_extensions.hpp:242
constexpr auto greater
Functional object, which compares its two operands greater.
Definition: Compare.hpp:71
constexpr auto less_equal
Functional object, which compares its two operands less-equal.
Definition: Compare.hpp:50
constexpr auto three_way
Functional object, which performs a three-way comparison on its two operands..
Definition: Compare.hpp:154
constexpr auto less
Functional object, which compares its two operands less.
Definition: Compare.hpp:29
constexpr auto not_equal
Functional object, which compares its two operands not-equal.
Definition: Compare.hpp:134
constexpr auto equal
Functional object, which compares its two operands equal.
Definition: Compare.hpp:113
constexpr auto greater_equal
Functional object, which compares its two operands greater-equal.
Definition: Compare.hpp:92
Definition: Compare.hpp:16