@@ -120,8 +120,7 @@ enum class ncmp : value_type { unordered = -127 };
120120// A no-op expansion that can be followed by a semicolon at class level.
121121#define ABSL_COMPARE_INLINE_BASECLASS_DECL (name ) static_assert (true , " " )
122122
123- #define ABSL_COMPARE_INLINE_SUBCLASS_DECL (type, name ) \
124- static const type name
123+ #define ABSL_COMPARE_INLINE_SUBCLASS_DECL (type, name ) static const type name
125124
126125#define ABSL_COMPARE_INLINE_INIT (type, name, init ) \
127126 inline constexpr type type::name (init)
@@ -190,28 +189,28 @@ class partial_ordering
190189 ABSL_COMPARE_INLINE_SUBCLASS_DECL (partial_ordering, unordered);
191190
192191 // Comparisons
193- friend constexpr bool operator ==(
194- partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
192+ friend constexpr bool operator ==(partial_ordering v,
193+ compare_internal::OnlyLiteralZero) noexcept {
195194 return v.is_ordered () && v.value_ == 0 ;
196195 }
197- friend constexpr bool operator !=(
198- partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
196+ friend constexpr bool operator !=(partial_ordering v,
197+ compare_internal::OnlyLiteralZero) noexcept {
199198 return !v.is_ordered () || v.value_ != 0 ;
200199 }
201- friend constexpr bool operator <(
202- partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
200+ friend constexpr bool operator <(partial_ordering v,
201+ compare_internal::OnlyLiteralZero) noexcept {
203202 return v.is_ordered () && v.value_ < 0 ;
204203 }
205- friend constexpr bool operator <=(
206- partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
204+ friend constexpr bool operator <=(partial_ordering v,
205+ compare_internal::OnlyLiteralZero) noexcept {
207206 return v.is_ordered () && v.value_ <= 0 ;
208207 }
209- friend constexpr bool operator >(
210- partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
208+ friend constexpr bool operator >(partial_ordering v,
209+ compare_internal::OnlyLiteralZero) noexcept {
211210 return v.is_ordered () && v.value_ > 0 ;
212211 }
213- friend constexpr bool operator >=(
214- partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
212+ friend constexpr bool operator >=(partial_ordering v,
213+ compare_internal::OnlyLiteralZero) noexcept {
215214 return v.is_ordered () && v.value_ >= 0 ;
216215 }
217216 friend constexpr bool operator ==(compare_internal::OnlyLiteralZero,
@@ -278,28 +277,28 @@ class weak_ordering
278277 : partial_ordering::greater);
279278 }
280279 // Comparisons
281- friend constexpr bool operator ==(
282- weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
280+ friend constexpr bool operator ==(weak_ordering v,
281+ compare_internal::OnlyLiteralZero) noexcept {
283282 return v.value_ == 0 ;
284283 }
285- friend constexpr bool operator !=(
286- weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
284+ friend constexpr bool operator !=(weak_ordering v,
285+ compare_internal::OnlyLiteralZero) noexcept {
287286 return v.value_ != 0 ;
288287 }
289- friend constexpr bool operator <(
290- weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
288+ friend constexpr bool operator <(weak_ordering v,
289+ compare_internal::OnlyLiteralZero) noexcept {
291290 return v.value_ < 0 ;
292291 }
293- friend constexpr bool operator <=(
294- weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
292+ friend constexpr bool operator <=(weak_ordering v,
293+ compare_internal::OnlyLiteralZero) noexcept {
295294 return v.value_ <= 0 ;
296295 }
297- friend constexpr bool operator >(
298- weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
296+ friend constexpr bool operator >(weak_ordering v,
297+ compare_internal::OnlyLiteralZero) noexcept {
299298 return v.value_ > 0 ;
300299 }
301- friend constexpr bool operator >=(
302- weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
300+ friend constexpr bool operator >=(weak_ordering v,
301+ compare_internal::OnlyLiteralZero) noexcept {
303302 return v.value_ >= 0 ;
304303 }
305304 friend constexpr bool operator ==(compare_internal::OnlyLiteralZero,
@@ -370,28 +369,28 @@ class strong_ordering
370369 : (value_ < 0 ? weak_ordering::less : weak_ordering::greater);
371370 }
372371 // Comparisons
373- friend constexpr bool operator ==(
374- strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
372+ friend constexpr bool operator ==(strong_ordering v,
373+ compare_internal::OnlyLiteralZero) noexcept {
375374 return v.value_ == 0 ;
376375 }
377- friend constexpr bool operator !=(
378- strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
376+ friend constexpr bool operator !=(strong_ordering v,
377+ compare_internal::OnlyLiteralZero) noexcept {
379378 return v.value_ != 0 ;
380379 }
381- friend constexpr bool operator <(
382- strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
380+ friend constexpr bool operator <(strong_ordering v,
381+ compare_internal::OnlyLiteralZero) noexcept {
383382 return v.value_ < 0 ;
384383 }
385- friend constexpr bool operator <=(
386- strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
384+ friend constexpr bool operator <=(strong_ordering v,
385+ compare_internal::OnlyLiteralZero) noexcept {
387386 return v.value_ <= 0 ;
388387 }
389- friend constexpr bool operator >(
390- strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
388+ friend constexpr bool operator >(strong_ordering v,
389+ compare_internal::OnlyLiteralZero) noexcept {
391390 return v.value_ > 0 ;
392391 }
393- friend constexpr bool operator >=(
394- strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
392+ friend constexpr bool operator >=(strong_ordering v,
393+ compare_internal::OnlyLiteralZero) noexcept {
395394 return v.value_ >= 0 ;
396395 }
397396 friend constexpr bool operator ==(compare_internal::OnlyLiteralZero,
@@ -451,14 +450,16 @@ namespace compare_internal {
451450// SFINAE prevents implicit conversions to bool (such as from int).
452451template <typename BoolT,
453452 absl::enable_if_t <std::is_same<bool , BoolT>::value, int > = 0 >
454- constexpr bool compare_result_as_less_than (const BoolT r) { return r; }
453+ constexpr bool compare_result_as_less_than (const BoolT r) {
454+ return r;
455+ }
455456constexpr bool compare_result_as_less_than (const absl::weak_ordering r) {
456457 return r < 0 ;
457458}
458459
459460template <typename Compare, typename K, typename LK>
460- constexpr bool do_less_than_comparison (const Compare & compare, const K & x,
461- const LK & y) {
461+ constexpr bool do_less_than_comparison (const Compare& compare, const K& x,
462+ const LK& y) {
462463 return compare_result_as_less_than (compare (x, y));
463464}
464465
@@ -468,34 +469,34 @@ constexpr bool do_less_than_comparison(const Compare &compare, const K &x,
468469template <typename Int,
469470 absl::enable_if_t <std::is_same<int , Int>::value, int > = 0 >
470471constexpr absl::weak_ordering compare_result_as_ordering (const Int c) {
471- return c < 0 ? absl::weak_ordering::less
472- : c == 0 ? absl::weak_ordering::equivalent
473- : absl::weak_ordering::greater;
472+ return c < 0 ? absl::weak_ordering::less
473+ : c == 0 ? absl::weak_ordering::equivalent
474+ : absl::weak_ordering::greater;
474475}
475476constexpr absl::weak_ordering compare_result_as_ordering (
476477 const absl::weak_ordering c) {
477478 return c;
478479}
479480
480- template <
481- typename Compare, typename K, typename LK,
482- absl:: enable_if_t < !std::is_same<bool , absl:: result_of_t <Compare(
483- const K &, const LK &)>>::value,
484- int > = 0 >
485- constexpr absl::weak_ordering do_three_way_comparison (const Compare & compare,
486- const K & x, const LK & y) {
481+ template <typename Compare, typename K, typename LK,
482+ absl:: enable_if_t <
483+ !std::is_same<
484+ bool , absl:: result_of_t <Compare( const K&, const LK&)>>::value,
485+ int > = 0 >
486+ constexpr absl::weak_ordering do_three_way_comparison (const Compare& compare,
487+ const K& x, const LK& y) {
487488 return compare_result_as_ordering (compare (x, y));
488489}
489- template <
490- typename Compare, typename K, typename LK,
491- absl:: enable_if_t < std::is_same<bool , absl:: result_of_t <Compare(
492- const K &, const LK &)>>::value,
493- int > = 0 >
494- constexpr absl::weak_ordering do_three_way_comparison (const Compare & compare,
495- const K & x, const LK & y) {
496- return compare (x, y) ? absl::weak_ordering::less
497- : compare (y, x) ? absl::weak_ordering::greater
498- : absl::weak_ordering::equivalent;
490+ template <typename Compare, typename K, typename LK,
491+ absl:: enable_if_t <
492+ std::is_same<
493+ bool , absl:: result_of_t <Compare( const K&, const LK&)>>::value,
494+ int > = 0 >
495+ constexpr absl::weak_ordering do_three_way_comparison (const Compare& compare,
496+ const K& x, const LK& y) {
497+ return compare (x, y) ? absl::weak_ordering::less
498+ : compare (y, x) ? absl::weak_ordering::greater
499+ : absl::weak_ordering::equivalent;
499500}
500501
501502} // namespace compare_internal
0 commit comments