30 #ifndef ABSL_TYPES_COMPARE_H_ 31 #define ABSL_TYPES_COMPARE_H_ 36 #include <type_traits> 42 namespace compare_internal {
48 static_assert(
sizeof(T) < 0,
"Only literal `0` is allowed.");
53 template <
typename NullPtrT = std::
nullptr_t>
64 typename =
typename std::enable_if<
102 template <
typename T>
104 template <
typename T>
106 template <
typename T>
108 template <
typename T>
111 template <
typename T>
118 template <
typename T>
120 template <
typename T>
122 template <
typename T>
124 template <
typename T>
127 template <
typename T>
133 template <
typename T>
135 template <
typename T>
137 template <
typename T>
140 template <
typename T>
147 template <
typename T>
149 template <
typename T>
151 template <
typename T>
153 template <
typename T>
161 : value_(static_cast<compare_internal::value_type>(
v)) {}
168 return v.value_ == 0;
172 return v.value_ != 0;
176 return 0 ==
v.value_;
180 return 0 !=
v.value_;
190 : value_(static_cast<compare_internal::value_type>(
v)) {}
202 return v.value_ == 0;
206 return v.value_ != 0;
210 return 0 ==
v.value_;
214 return 0 !=
v.value_;
224 : value_(static_cast<compare_internal::value_type>(
v)) {}
226 : value_(static_cast<compare_internal::value_type>(
v)) {}
228 : value_(static_cast<compare_internal::value_type>(
v)) {}
245 return v.is_ordered() &&
v.value_ == 0;
249 return !
v.is_ordered() ||
v.value_ != 0;
253 return v.is_ordered() &&
v.value_ < 0;
257 return v.is_ordered() &&
v.value_ <= 0;
261 return v.is_ordered() &&
v.value_ > 0;
265 return v.is_ordered() &&
v.value_ >= 0;
269 return v.is_ordered() && 0 ==
v.value_;
273 return !
v.is_ordered() || 0 !=
v.value_;
275 friend constexpr
bool operator<(compare_internal::OnlyLiteralZero<>,
277 return v.is_ordered() && 0 <
v.value_;
279 friend constexpr
bool operator<=(compare_internal::OnlyLiteralZero<>,
281 return v.is_ordered() && 0 <=
v.value_;
285 return v.is_ordered() && 0 >
v.value_;
289 return v.is_ordered() && 0 >=
v.value_;
299 : value_(static_cast<compare_internal::value_type>(
v)) {}
301 : value_(static_cast<compare_internal::value_type>(
v)) {}
318 return v.value_ == 0;
322 return v.value_ != 0;
330 return v.value_ <= 0;
338 return v.value_ >= 0;
342 return 0 ==
v.value_;
346 return 0 !=
v.value_;
348 friend constexpr
bool operator<(compare_internal::OnlyLiteralZero<>,
352 friend constexpr
bool operator<=(compare_internal::OnlyLiteralZero<>,
354 return 0 <=
v.value_;
362 return 0 >=
v.value_;
372 : value_(static_cast<compare_internal::value_type>(
v)) {}
374 : value_(static_cast<compare_internal::value_type>(
v)) {}
399 return v.value_ == 0;
403 return v.value_ != 0;
411 return v.value_ <= 0;
419 return v.value_ >= 0;
423 return 0 ==
v.value_;
427 return 0 !=
v.value_;
429 friend constexpr
bool operator<(compare_internal::OnlyLiteralZero<>,
433 friend constexpr
bool operator<=(compare_internal::OnlyLiteralZero<>,
435 return 0 <=
v.value_;
443 return 0 >=
v.value_;
450 namespace compare_internal {
456 template <
typename Bool,
463 template <
typename Compare,
typename K,
typename LK>
472 template <
typename Int,
485 typename Compare,
typename K,
typename LK,
487 const K &,
const LK &)>>
::value,
490 const K &x,
const LK &y) {
494 typename Compare,
typename K,
typename LK,
496 const K &,
const LK &)>>
::value,
499 const K &x,
const LK &y) {
508 #endif // ABSL_TYPES_COMPARE_H_
friend constexpr bool operator!=(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
friend constexpr bool operator>(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
static ABSL_CONST_INIT const T unordered
friend constexpr bool operator==(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
constexpr weak_ordering(compare_internal::ord v) noexcept
static ABSL_CONST_INIT const T equivalent
constexpr strong_ordering(compare_internal::ord v) noexcept
friend constexpr bool operator<=(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
typename std::result_of< T >::type result_of_t
static ABSL_CONST_INIT const T greater
static ABSL_CONST_INIT const T equivalent
friend constexpr bool operator!=(strong_equality v, compare_internal::OnlyLiteralZero<>) noexcept
constexpr bool do_less_than_comparison(const Compare &compare, const K &x, const LK &y)
constexpr bool compare_result_as_less_than(const Bool r)
static ABSL_CONST_INIT const T equal
friend constexpr bool operator>(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
constexpr absl::weak_ordering compare_result_as_ordering(const Int c)
compare_internal::value_type value_
friend constexpr bool operator==(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
static ABSL_CONST_INIT const T less
constexpr strong_equality(compare_internal::eq v) noexcept
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
compare_internal::value_type value_
constexpr weak_ordering(compare_internal::eq v) noexcept
constexpr weak_equality(compare_internal::eq v) noexcept
friend constexpr bool operator<=(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, strong_equality v) noexcept
static ABSL_CONST_INIT const T greater
friend constexpr bool operator<(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
friend constexpr bool operator<(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
typename std::enable_if< B, T >::type enable_if_t
friend constexpr bool operator>=(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
constexpr partial_ordering(compare_internal::ord v) noexcept
friend constexpr bool operator!=(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
constexpr partial_ordering(compare_internal::eq v) noexcept
static ABSL_CONST_INIT const T nonequivalent
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
constexpr bool is_ordered() const noexcept
friend constexpr bool operator>=(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
friend constexpr bool operator>=(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
friend constexpr bool operator>=(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
static ABSL_CONST_INIT const T nonequal
constexpr absl::weak_ordering do_three_way_comparison(const Compare &compare, const K &x, const LK &y)
static ABSL_CONST_INIT const T equivalent
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, weak_equality v) noexcept
constexpr OnlyLiteralZero(NullPtrT) noexcept
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, strong_equality v) noexcept
friend constexpr bool operator==(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
friend constexpr bool operator!=(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
static ABSL_CONST_INIT const T nonequivalent
friend constexpr bool operator<=(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, weak_equality v) noexcept
friend constexpr bool operator>(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
friend constexpr bool operator>(compare_internal::OnlyLiteralZero<>, strong_ordering v) noexcept
static ABSL_CONST_INIT const T less
friend constexpr bool operator<(weak_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
compare_internal::value_type value_
static ABSL_CONST_INIT const T equal
friend constexpr bool operator==(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
static ABSL_CONST_INIT const T less
friend constexpr bool operator>(compare_internal::OnlyLiteralZero<>, partial_ordering v) noexcept
friend constexpr bool operator==(strong_equality v, compare_internal::OnlyLiteralZero<>) noexcept
friend constexpr bool operator!=(weak_equality v, compare_internal::OnlyLiteralZero<>) noexcept
constexpr partial_ordering(compare_internal::ncmp v) noexcept
int Compare(const BigUnsigned< N > &lhs, const BigUnsigned< M > &rhs)
compare_internal::value_type value_
friend constexpr bool operator>(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
friend constexpr bool operator!=(compare_internal::OnlyLiteralZero<>, weak_ordering v) noexcept
friend constexpr bool operator>=(strong_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
constexpr strong_ordering(compare_internal::eq v) noexcept
friend constexpr bool operator>=(partial_ordering v, compare_internal::OnlyLiteralZero<>) noexcept
static ABSL_CONST_INIT const T equivalent
static ABSL_CONST_INIT const T equivalent
friend constexpr bool operator==(weak_equality v, compare_internal::OnlyLiteralZero<>) noexcept
compare_internal::value_type value_
static ABSL_CONST_INIT const T greater