Skip to content

Commit ab4f684

Browse files
jacobsacopybara-github
authored andcommitted
absl/types: format code with clang-format.
PiperOrigin-RevId: 820434760 Change-Id: I70e5e4b6a433137e55d4ec27be04f6acd46ad649
1 parent d6c9f93 commit ab4f684

File tree

5 files changed

+70
-68
lines changed

5 files changed

+70
-68
lines changed

absl/types/compare.h

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -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).
452451
template <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+
}
455456
constexpr bool compare_result_as_less_than(const absl::weak_ordering r) {
456457
return r < 0;
457458
}
458459

459460
template <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,
468469
template <typename Int,
469470
absl::enable_if_t<std::is_same<int, Int>::value, int> = 0>
470471
constexpr 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
}
475476
constexpr 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

absl/types/compare_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ TEST(Compare, Conversions) {
160160
struct WeakOrderingLess {
161161
template <typename T>
162162
absl::weak_ordering operator()(const T& a, const T& b) const {
163-
return a < b ? absl::weak_ordering::less
164-
: a == b ? absl::weak_ordering::equivalent
165-
: absl::weak_ordering::greater;
163+
return a < b ? absl::weak_ordering::less
164+
: a == b ? absl::weak_ordering::equivalent
165+
: absl::weak_ordering::greater;
166166
}
167167
};
168168

absl/types/internal/span.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct IsView<
121121
using ConstData =
122122
decltype(span_internal::GetData(std::declval<const Container&>()));
123123
using MutData = decltype(span_internal::GetData(std::declval<Container&>()));
124+
124125
public:
125126
static constexpr bool value = std::is_same<ConstData, MutData>::value;
126127
};

absl/types/optional.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
namespace absl {
3232
ABSL_NAMESPACE_BEGIN
3333
using std::bad_optional_access;
34-
using std::optional;
3534
using std::make_optional;
36-
using std::nullopt_t;
3735
using std::nullopt;
36+
using std::nullopt_t;
37+
using std::optional;
3838
ABSL_NAMESPACE_END
3939
} // namespace absl
4040

absl/types/span.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ ABSL_NAMESPACE_END
9191
#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L
9292
#include <ranges> // NOLINT(build/c++20)
9393
template <typename T>
94-
// NOLINTNEXTLINE(build/c++20)
94+
// NOLINTNEXTLINE(build/c++20)
9595
inline constexpr bool std::ranges::enable_view<absl::Span<T>> = true;
9696
template <typename T>
97-
// NOLINTNEXTLINE(build/c++20)
97+
// NOLINTNEXTLINE(build/c++20)
9898
inline constexpr bool std::ranges::enable_borrowed_range<absl::Span<T>> = true;
9999
#endif
100100

0 commit comments

Comments
 (0)