mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
absl/types: format code with clang-format.
PiperOrigin-RevId: 820434760 Change-Id: I70e5e4b6a433137e55d4ec27be04f6acd46ad649
This commit is contained in:
committed by
Copybara-Service
parent
d6c9f93ab6
commit
ab4f684de4
@@ -120,8 +120,7 @@ enum class ncmp : value_type { unordered = -127 };
|
||||
// A no-op expansion that can be followed by a semicolon at class level.
|
||||
#define ABSL_COMPARE_INLINE_BASECLASS_DECL(name) static_assert(true, "")
|
||||
|
||||
#define ABSL_COMPARE_INLINE_SUBCLASS_DECL(type, name) \
|
||||
static const type name
|
||||
#define ABSL_COMPARE_INLINE_SUBCLASS_DECL(type, name) static const type name
|
||||
|
||||
#define ABSL_COMPARE_INLINE_INIT(type, name, init) \
|
||||
inline constexpr type type::name(init)
|
||||
@@ -190,28 +189,28 @@ class partial_ordering
|
||||
ABSL_COMPARE_INLINE_SUBCLASS_DECL(partial_ordering, unordered);
|
||||
|
||||
// Comparisons
|
||||
friend constexpr bool operator==(
|
||||
partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator==(partial_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.is_ordered() && v.value_ == 0;
|
||||
}
|
||||
friend constexpr bool operator!=(
|
||||
partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator!=(partial_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return !v.is_ordered() || v.value_ != 0;
|
||||
}
|
||||
friend constexpr bool operator<(
|
||||
partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator<(partial_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.is_ordered() && v.value_ < 0;
|
||||
}
|
||||
friend constexpr bool operator<=(
|
||||
partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator<=(partial_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.is_ordered() && v.value_ <= 0;
|
||||
}
|
||||
friend constexpr bool operator>(
|
||||
partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator>(partial_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.is_ordered() && v.value_ > 0;
|
||||
}
|
||||
friend constexpr bool operator>=(
|
||||
partial_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator>=(partial_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.is_ordered() && v.value_ >= 0;
|
||||
}
|
||||
friend constexpr bool operator==(compare_internal::OnlyLiteralZero,
|
||||
@@ -278,28 +277,28 @@ class weak_ordering
|
||||
: partial_ordering::greater);
|
||||
}
|
||||
// Comparisons
|
||||
friend constexpr bool operator==(
|
||||
weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator==(weak_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ == 0;
|
||||
}
|
||||
friend constexpr bool operator!=(
|
||||
weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator!=(weak_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ != 0;
|
||||
}
|
||||
friend constexpr bool operator<(
|
||||
weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator<(weak_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ < 0;
|
||||
}
|
||||
friend constexpr bool operator<=(
|
||||
weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator<=(weak_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ <= 0;
|
||||
}
|
||||
friend constexpr bool operator>(
|
||||
weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator>(weak_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ > 0;
|
||||
}
|
||||
friend constexpr bool operator>=(
|
||||
weak_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator>=(weak_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ >= 0;
|
||||
}
|
||||
friend constexpr bool operator==(compare_internal::OnlyLiteralZero,
|
||||
@@ -370,28 +369,28 @@ class strong_ordering
|
||||
: (value_ < 0 ? weak_ordering::less : weak_ordering::greater);
|
||||
}
|
||||
// Comparisons
|
||||
friend constexpr bool operator==(
|
||||
strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator==(strong_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ == 0;
|
||||
}
|
||||
friend constexpr bool operator!=(
|
||||
strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator!=(strong_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ != 0;
|
||||
}
|
||||
friend constexpr bool operator<(
|
||||
strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator<(strong_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ < 0;
|
||||
}
|
||||
friend constexpr bool operator<=(
|
||||
strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator<=(strong_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ <= 0;
|
||||
}
|
||||
friend constexpr bool operator>(
|
||||
strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator>(strong_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ > 0;
|
||||
}
|
||||
friend constexpr bool operator>=(
|
||||
strong_ordering v, compare_internal::OnlyLiteralZero) noexcept {
|
||||
friend constexpr bool operator>=(strong_ordering v,
|
||||
compare_internal::OnlyLiteralZero) noexcept {
|
||||
return v.value_ >= 0;
|
||||
}
|
||||
friend constexpr bool operator==(compare_internal::OnlyLiteralZero,
|
||||
@@ -451,14 +450,16 @@ namespace compare_internal {
|
||||
// SFINAE prevents implicit conversions to bool (such as from int).
|
||||
template <typename BoolT,
|
||||
absl::enable_if_t<std::is_same<bool, BoolT>::value, int> = 0>
|
||||
constexpr bool compare_result_as_less_than(const BoolT r) { return r; }
|
||||
constexpr bool compare_result_as_less_than(const BoolT r) {
|
||||
return r;
|
||||
}
|
||||
constexpr bool compare_result_as_less_than(const absl::weak_ordering r) {
|
||||
return r < 0;
|
||||
}
|
||||
|
||||
template <typename Compare, typename K, typename LK>
|
||||
constexpr bool do_less_than_comparison(const Compare &compare, const K &x,
|
||||
const LK &y) {
|
||||
constexpr bool do_less_than_comparison(const Compare& compare, const K& x,
|
||||
const LK& y) {
|
||||
return compare_result_as_less_than(compare(x, y));
|
||||
}
|
||||
|
||||
@@ -468,34 +469,34 @@ constexpr bool do_less_than_comparison(const Compare &compare, const K &x,
|
||||
template <typename Int,
|
||||
absl::enable_if_t<std::is_same<int, Int>::value, int> = 0>
|
||||
constexpr absl::weak_ordering compare_result_as_ordering(const Int c) {
|
||||
return c < 0 ? absl::weak_ordering::less
|
||||
: c == 0 ? absl::weak_ordering::equivalent
|
||||
: absl::weak_ordering::greater;
|
||||
return c < 0 ? absl::weak_ordering::less
|
||||
: c == 0 ? absl::weak_ordering::equivalent
|
||||
: absl::weak_ordering::greater;
|
||||
}
|
||||
constexpr absl::weak_ordering compare_result_as_ordering(
|
||||
const absl::weak_ordering c) {
|
||||
return c;
|
||||
}
|
||||
|
||||
template <
|
||||
typename Compare, typename K, typename LK,
|
||||
absl::enable_if_t<!std::is_same<bool, absl::result_of_t<Compare(
|
||||
const K &, const LK &)>>::value,
|
||||
int> = 0>
|
||||
constexpr absl::weak_ordering do_three_way_comparison(const Compare &compare,
|
||||
const K &x, const LK &y) {
|
||||
template <typename Compare, typename K, typename LK,
|
||||
absl::enable_if_t<
|
||||
!std::is_same<
|
||||
bool, absl::result_of_t<Compare(const K&, const LK&)>>::value,
|
||||
int> = 0>
|
||||
constexpr absl::weak_ordering do_three_way_comparison(const Compare& compare,
|
||||
const K& x, const LK& y) {
|
||||
return compare_result_as_ordering(compare(x, y));
|
||||
}
|
||||
template <
|
||||
typename Compare, typename K, typename LK,
|
||||
absl::enable_if_t<std::is_same<bool, absl::result_of_t<Compare(
|
||||
const K &, const LK &)>>::value,
|
||||
int> = 0>
|
||||
constexpr absl::weak_ordering do_three_way_comparison(const Compare &compare,
|
||||
const K &x, const LK &y) {
|
||||
return compare(x, y) ? absl::weak_ordering::less
|
||||
: compare(y, x) ? absl::weak_ordering::greater
|
||||
: absl::weak_ordering::equivalent;
|
||||
template <typename Compare, typename K, typename LK,
|
||||
absl::enable_if_t<
|
||||
std::is_same<
|
||||
bool, absl::result_of_t<Compare(const K&, const LK&)>>::value,
|
||||
int> = 0>
|
||||
constexpr absl::weak_ordering do_three_way_comparison(const Compare& compare,
|
||||
const K& x, const LK& y) {
|
||||
return compare(x, y) ? absl::weak_ordering::less
|
||||
: compare(y, x) ? absl::weak_ordering::greater
|
||||
: absl::weak_ordering::equivalent;
|
||||
}
|
||||
|
||||
} // namespace compare_internal
|
||||
|
||||
@@ -160,9 +160,9 @@ TEST(Compare, Conversions) {
|
||||
struct WeakOrderingLess {
|
||||
template <typename T>
|
||||
absl::weak_ordering operator()(const T& a, const T& b) const {
|
||||
return a < b ? absl::weak_ordering::less
|
||||
: a == b ? absl::weak_ordering::equivalent
|
||||
: absl::weak_ordering::greater;
|
||||
return a < b ? absl::weak_ordering::less
|
||||
: a == b ? absl::weak_ordering::equivalent
|
||||
: absl::weak_ordering::greater;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@ struct IsView<
|
||||
using ConstData =
|
||||
decltype(span_internal::GetData(std::declval<const Container&>()));
|
||||
using MutData = decltype(span_internal::GetData(std::declval<Container&>()));
|
||||
|
||||
public:
|
||||
static constexpr bool value = std::is_same<ConstData, MutData>::value;
|
||||
};
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
using std::bad_optional_access;
|
||||
using std::optional;
|
||||
using std::make_optional;
|
||||
using std::nullopt_t;
|
||||
using std::nullopt;
|
||||
using std::nullopt_t;
|
||||
using std::optional;
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
|
||||
@@ -91,10 +91,10 @@ ABSL_NAMESPACE_END
|
||||
#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L
|
||||
#include <ranges> // NOLINT(build/c++20)
|
||||
template <typename T>
|
||||
// NOLINTNEXTLINE(build/c++20)
|
||||
// NOLINTNEXTLINE(build/c++20)
|
||||
inline constexpr bool std::ranges::enable_view<absl::Span<T>> = true;
|
||||
template <typename T>
|
||||
// NOLINTNEXTLINE(build/c++20)
|
||||
// NOLINTNEXTLINE(build/c++20)
|
||||
inline constexpr bool std::ranges::enable_borrowed_range<absl::Span<T>> = true;
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user