修改pods

This commit is contained in:
2025-09-20 17:13:38 +08:00
parent 7787b3ee30
commit 28ff2b0264
5251 changed files with 345029 additions and 285168 deletions

View File

@@ -123,11 +123,70 @@ using IsForwardingAssignmentValid = absl::disjunction<
std::is_same<absl::in_place_t, absl::remove_cvref_t<U>>,
IsForwardingAssignmentAmbiguous<T, U>>>>;
template <bool Value, typename T>
using Equality = std::conditional_t<Value, T, absl::negation<T>>;
template <bool Explicit, typename T, typename U, bool Lifetimebound>
using IsConstructionValid = absl::conjunction<
Equality<Lifetimebound,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>,
IsDirectInitializationValid<T, U&&>, std::is_constructible<T, U&&>,
Equality<!Explicit, std::is_convertible<U&&, T>>,
absl::disjunction<
std::is_same<T, absl::remove_cvref_t<U>>,
absl::conjunction<
std::conditional_t<
Explicit,
absl::negation<std::is_constructible<absl::Status, U&&>>,
absl::negation<std::is_convertible<U&&, absl::Status>>>,
absl::negation<
internal_statusor::HasConversionOperatorToStatusOr<T, U&&>>>>>;
template <typename T, typename U, bool Lifetimebound>
using IsAssignmentValid = absl::conjunction<
Equality<Lifetimebound,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>,
std::is_constructible<T, U&&>, std::is_assignable<T&, U&&>,
absl::disjunction<
std::is_same<T, absl::remove_cvref_t<U>>,
absl::conjunction<
absl::negation<std::is_convertible<U&&, absl::Status>>,
absl::negation<HasConversionOperatorToStatusOr<T, U&&>>>>,
IsForwardingAssignmentValid<T, U&&>>;
template <bool Explicit, typename T, typename U>
using IsConstructionFromStatusValid = absl::conjunction<
absl::negation<std::is_same<absl::StatusOr<T>, absl::remove_cvref_t<U>>>,
absl::negation<std::is_same<T, absl::remove_cvref_t<U>>>,
absl::negation<std::is_same<absl::in_place_t, absl::remove_cvref_t<U>>>,
Equality<!Explicit, std::is_convertible<U, absl::Status>>,
std::is_constructible<absl::Status, U>,
absl::negation<HasConversionOperatorToStatusOr<T, U>>>;
template <bool Explicit, typename T, typename U, bool Lifetimebound,
typename UQ>
using IsConstructionFromStatusOrValid = absl::conjunction<
absl::negation<std::is_same<T, U>>,
Equality<Lifetimebound,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>,
std::is_constructible<T, UQ>,
Equality<!Explicit, std::is_convertible<UQ, T>>,
absl::negation<IsConstructibleOrConvertibleFromStatusOr<T, U>>>;
template <typename T, typename U, bool Lifetimebound>
using IsStatusOrAssignmentValid = absl::conjunction<
absl::negation<std::is_same<T, absl::remove_cvref_t<U>>>,
Equality<Lifetimebound,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>,
std::is_constructible<T, U>, std::is_assignable<T, U>,
absl::negation<IsConstructibleOrConvertibleOrAssignableFromStatusOr<
T, absl::remove_cvref_t<U>>>>;
class Helper {
public:
// Move type-agnostic error handling to the .cc.
static void HandleInvalidStatusCtorArg(absl::Nonnull<Status*>);
ABSL_ATTRIBUTE_NORETURN static void Crash(const absl::Status& status);
[[noreturn]] static void Crash(const absl::Status& status);
};
// Construct an instance of T in `p` through placement new, passing Args... to
@@ -379,7 +438,7 @@ struct MoveAssignBase<T, false> {
MoveAssignBase& operator=(MoveAssignBase&&) = delete;
};
ABSL_ATTRIBUTE_NORETURN void ThrowBadStatusOrAccess(absl::Status status);
[[noreturn]] void ThrowBadStatusOrAccess(absl::Status status);
// Used to introduce jitter into the output of printing functions for
// `StatusOr` (i.e. `AbslStringify` and `operator<<`).

View File

@@ -273,14 +273,12 @@ StatusCode ErrnoToStatusCode(int error_number) {
case EFAULT: // Bad address
case EILSEQ: // Illegal byte sequence
case ENOPROTOOPT: // Protocol not available
case ENOSTR: // Not a STREAM
case ENOTSOCK: // Not a socket
case ENOTTY: // Inappropriate I/O control operation
case EPROTOTYPE: // Protocol wrong type for socket
case ESPIPE: // Invalid seek
return StatusCode::kInvalidArgument;
case ETIMEDOUT: // Connection timed out
case ETIME: // Timer expired
return StatusCode::kDeadlineExceeded;
case ENODEV: // No such device
case ENOENT: // No such file or directory
@@ -339,9 +337,7 @@ StatusCode ErrnoToStatusCode(int error_number) {
case EMLINK: // Too many links
case ENFILE: // Too many open files in system
case ENOBUFS: // No buffer space available
case ENODATA: // No message is available on the STREAM read queue
case ENOMEM: // Not enough space
case ENOSR: // No STREAM resources
#ifdef EUSERS
case EUSERS: // Too many users
#endif

View File

@@ -452,7 +452,7 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI Status final {
// The moved-from state is valid but unspecified.
Status(Status&&) noexcept;
Status& operator=(Status&&);
Status& operator=(Status&&) noexcept;
~Status();
@@ -539,7 +539,7 @@ class ABSL_ATTRIBUTE_TRIVIAL_ABI Status final {
// swap()
//
// Swap the contents of one status with another.
friend void swap(Status& a, Status& b);
friend void swap(Status& a, Status& b) noexcept;
//----------------------------------------------------------------------------
// Payload Management APIs
@@ -789,7 +789,7 @@ inline Status::Status(Status&& x) noexcept : Status(x.rep_) {
x.rep_ = MovedFromRep();
}
inline Status& Status::operator=(Status&& x) {
inline Status& Status::operator=(Status&& x) noexcept {
uintptr_t old_rep = rep_;
if (x.rep_ != old_rep) {
rep_ = x.rep_;
@@ -852,7 +852,7 @@ inline void Status::IgnoreError() const {
// no-op
}
inline void swap(absl::Status& a, absl::Status& b) {
inline void swap(absl::Status& a, absl::Status& b) noexcept {
using std::swap;
swap(a.rep_, b.rep_);
}

View File

@@ -236,57 +236,55 @@ class StatusOr : private internal_statusor::StatusOrData<T>,
// is explicit if and only if the corresponding construction of `T` from `U`
// is explicit. (This constructor inherits its explicitness from the
// underlying constructor.)
template <
typename U,
absl::enable_if_t<
absl::conjunction<
absl::negation<std::is_same<T, U>>,
std::is_constructible<T, const U&>,
std::is_convertible<const U&, T>,
absl::negation<
internal_statusor::IsConstructibleOrConvertibleFromStatusOr<
T, U>>>::value,
int> = 0>
template <typename U, absl::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
false, T, U, false, const U&>::value,
int> = 0>
StatusOr(const StatusOr<U>& other) // NOLINT
: Base(static_cast<const typename StatusOr<U>::Base&>(other)) {}
template <
typename U,
absl::enable_if_t<
absl::conjunction<
absl::negation<std::is_same<T, U>>,
std::is_constructible<T, const U&>,
absl::negation<std::is_convertible<const U&, T>>,
absl::negation<
internal_statusor::IsConstructibleOrConvertibleFromStatusOr<
T, U>>>::value,
int> = 0>
template <typename U, absl::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
false, T, U, true, const U&>::value,
int> = 0>
StatusOr(const StatusOr<U>& other ABSL_ATTRIBUTE_LIFETIME_BOUND) // NOLINT
: Base(static_cast<const typename StatusOr<U>::Base&>(other)) {}
template <typename U, absl::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
true, T, U, false, const U&>::value,
int> = 0>
explicit StatusOr(const StatusOr<U>& other)
: Base(static_cast<const typename StatusOr<U>::Base&>(other)) {}
template <typename U, absl::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
true, T, U, true, const U&>::value,
int> = 0>
explicit StatusOr(const StatusOr<U>& other ABSL_ATTRIBUTE_LIFETIME_BOUND)
: Base(static_cast<const typename StatusOr<U>::Base&>(other)) {}
template <
typename U,
absl::enable_if_t<
absl::conjunction<
absl::negation<std::is_same<T, U>>, std::is_constructible<T, U&&>,
std::is_convertible<U&&, T>,
absl::negation<
internal_statusor::IsConstructibleOrConvertibleFromStatusOr<
T, U>>>::value,
int> = 0>
template <typename U, absl::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
false, T, U, false, U&&>::value,
int> = 0>
StatusOr(StatusOr<U>&& other) // NOLINT
: Base(static_cast<typename StatusOr<U>::Base&&>(other)) {}
template <
typename U,
absl::enable_if_t<
absl::conjunction<
absl::negation<std::is_same<T, U>>, std::is_constructible<T, U&&>,
absl::negation<std::is_convertible<U&&, T>>,
absl::negation<
internal_statusor::IsConstructibleOrConvertibleFromStatusOr<
T, U>>>::value,
int> = 0>
template <typename U, absl::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
false, T, U, true, U&&>::value,
int> = 0>
StatusOr(StatusOr<U>&& other ABSL_ATTRIBUTE_LIFETIME_BOUND) // NOLINT
: Base(static_cast<typename StatusOr<U>::Base&&>(other)) {}
template <typename U, absl::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
true, T, U, false, U&&>::value,
int> = 0>
explicit StatusOr(StatusOr<U>&& other)
: Base(static_cast<typename StatusOr<U>::Base&&>(other)) {}
template <typename U, absl::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
true, T, U, true, U&&>::value,
int> = 0>
explicit StatusOr(StatusOr<U>&& other ABSL_ATTRIBUTE_LIFETIME_BOUND)
: Base(static_cast<typename StatusOr<U>::Base&&>(other)) {}
// Converting Assignment Operators
@@ -307,37 +305,38 @@ class StatusOr : private internal_statusor::StatusOrData<T>,
// These overloads only apply if `absl::StatusOr<T>` is constructible and
// assignable from `absl::StatusOr<U>` and `StatusOr<T>` cannot be directly
// assigned from `StatusOr<U>`.
template <
typename U,
absl::enable_if_t<
absl::conjunction<
absl::negation<std::is_same<T, U>>,
std::is_constructible<T, const U&>,
std::is_assignable<T, const U&>,
absl::negation<
internal_statusor::
IsConstructibleOrConvertibleOrAssignableFromStatusOr<
T, U>>>::value,
int> = 0>
template <typename U,
absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
T, const U&, false>::value,
int> = 0>
StatusOr& operator=(const StatusOr<U>& other) {
this->Assign(other);
return *this;
}
template <
typename U,
absl::enable_if_t<
absl::conjunction<
absl::negation<std::is_same<T, U>>, std::is_constructible<T, U&&>,
std::is_assignable<T, U&&>,
absl::negation<
internal_statusor::
IsConstructibleOrConvertibleOrAssignableFromStatusOr<
T, U>>>::value,
int> = 0>
template <typename U,
absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
T, const U&, true>::value,
int> = 0>
StatusOr& operator=(const StatusOr<U>& other ABSL_ATTRIBUTE_LIFETIME_BOUND) {
this->Assign(other);
return *this;
}
template <typename U,
absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
T, U&&, false>::value,
int> = 0>
StatusOr& operator=(StatusOr<U>&& other) {
this->Assign(std::move(other));
return *this;
}
template <typename U,
absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
T, U&&, true>::value,
int> = 0>
StatusOr& operator=(StatusOr<U>&& other ABSL_ATTRIBUTE_LIFETIME_BOUND) {
this->Assign(std::move(other));
return *this;
}
// Constructs a new `absl::StatusOr<T>` with a non-ok status. After calling
// this constructor, `this->ok()` will be `false` and calls to `value()` will
@@ -350,46 +349,21 @@ class StatusOr : private internal_statusor::StatusOrData<T>,
// REQUIRES: !Status(std::forward<U>(v)).ok(). This requirement is DCHECKed.
// In optimized builds, passing absl::OkStatus() here will have the effect
// of passing absl::StatusCode::kInternal as a fallback.
template <
typename U = absl::Status,
absl::enable_if_t<
absl::conjunction<
std::is_convertible<U&&, absl::Status>,
std::is_constructible<absl::Status, U&&>,
absl::negation<std::is_same<absl::decay_t<U>, absl::StatusOr<T>>>,
absl::negation<std::is_same<absl::decay_t<U>, T>>,
absl::negation<std::is_same<absl::decay_t<U>, absl::in_place_t>>,
absl::negation<internal_statusor::HasConversionOperatorToStatusOr<
T, U&&>>>::value,
int> = 0>
template <typename U = absl::Status,
absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
false, T, U>::value,
int> = 0>
StatusOr(U&& v) : Base(std::forward<U>(v)) {}
template <
typename U = absl::Status,
absl::enable_if_t<
absl::conjunction<
absl::negation<std::is_convertible<U&&, absl::Status>>,
std::is_constructible<absl::Status, U&&>,
absl::negation<std::is_same<absl::decay_t<U>, absl::StatusOr<T>>>,
absl::negation<std::is_same<absl::decay_t<U>, T>>,
absl::negation<std::is_same<absl::decay_t<U>, absl::in_place_t>>,
absl::negation<internal_statusor::HasConversionOperatorToStatusOr<
T, U&&>>>::value,
int> = 0>
template <typename U = absl::Status,
absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
true, T, U>::value,
int> = 0>
explicit StatusOr(U&& v) : Base(std::forward<U>(v)) {}
template <
typename U = absl::Status,
absl::enable_if_t<
absl::conjunction<
std::is_convertible<U&&, absl::Status>,
std::is_constructible<absl::Status, U&&>,
absl::negation<std::is_same<absl::decay_t<U>, absl::StatusOr<T>>>,
absl::negation<std::is_same<absl::decay_t<U>, T>>,
absl::negation<std::is_same<absl::decay_t<U>, absl::in_place_t>>,
absl::negation<internal_statusor::HasConversionOperatorToStatusOr<
T, U&&>>>::value,
int> = 0>
template <typename U = absl::Status,
absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
false, T, U>::value,
int> = 0>
StatusOr& operator=(U&& v) {
this->AssignStatus(std::forward<U>(v));
return *this;
@@ -411,21 +385,22 @@ class StatusOr : private internal_statusor::StatusOrData<T>,
// StatusOr<bool> s1 = true; // s1.ok() && *s1 == true
// StatusOr<bool> s2 = false; // s2.ok() && *s2 == false
// s1 = s2; // ambiguous, `s1 = *s2` or `s1 = bool(s2)`?
template <
typename U = T,
typename = typename std::enable_if<absl::conjunction<
std::is_constructible<T, U&&>, std::is_assignable<T&, U&&>,
absl::disjunction<
std::is_same<absl::remove_cvref_t<U>, T>,
absl::conjunction<
absl::negation<std::is_convertible<U&&, absl::Status>>,
absl::negation<internal_statusor::
HasConversionOperatorToStatusOr<T, U&&>>>>,
internal_statusor::IsForwardingAssignmentValid<T, U&&>>::value>::type>
template <typename U = T,
typename std::enable_if<
internal_statusor::IsAssignmentValid<T, U, false>::value,
int>::type = 0>
StatusOr& operator=(U&& v) {
this->Assign(std::forward<U>(v));
return *this;
}
template <typename U = T,
typename std::enable_if<
internal_statusor::IsAssignmentValid<T, U, true>::value,
int>::type = 0>
StatusOr& operator=(U&& v ABSL_ATTRIBUTE_LIFETIME_BOUND) {
this->Assign(std::forward<U>(v));
return *this;
}
// Constructs the inner value `T` in-place using the provided args, using the
// `T(args...)` constructor.
@@ -442,40 +417,31 @@ class StatusOr : private internal_statusor::StatusOrData<T>,
// This constructor is explicit if `U` is not convertible to `T`. To avoid
// ambiguity, this constructor is disabled if `U` is a `StatusOr<J>`, where
// `J` is convertible to `T`.
template <
typename U = T,
absl::enable_if_t<
absl::conjunction<
internal_statusor::IsDirectInitializationValid<T, U&&>,
std::is_constructible<T, U&&>, std::is_convertible<U&&, T>,
absl::disjunction<
std::is_same<absl::remove_cvref_t<U>, T>,
absl::conjunction<
absl::negation<std::is_convertible<U&&, absl::Status>>,
absl::negation<
internal_statusor::HasConversionOperatorToStatusOr<
T, U&&>>>>>::value,
int> = 0>
template <typename U = T,
absl::enable_if_t<internal_statusor::IsConstructionValid<
false, T, U, false>::value,
int> = 0>
StatusOr(U&& u) // NOLINT
: StatusOr(absl::in_place, std::forward<U>(u)) {}
template <typename U = T,
absl::enable_if_t<internal_statusor::IsConstructionValid<
false, T, U, true>::value,
int> = 0>
StatusOr(U&& u ABSL_ATTRIBUTE_LIFETIME_BOUND) // NOLINT
: StatusOr(absl::in_place, std::forward<U>(u)) {}
template <
typename U = T,
absl::enable_if_t<
absl::conjunction<
internal_statusor::IsDirectInitializationValid<T, U&&>,
absl::disjunction<
std::is_same<absl::remove_cvref_t<U>, T>,
absl::conjunction<
absl::negation<std::is_constructible<absl::Status, U&&>>,
absl::negation<
internal_statusor::HasConversionOperatorToStatusOr<
T, U&&>>>>,
std::is_constructible<T, U&&>,
absl::negation<std::is_convertible<U&&, T>>>::value,
int> = 0>
template <typename U = T,
absl::enable_if_t<internal_statusor::IsConstructionValid<
true, T, U, false>::value,
int> = 0>
explicit StatusOr(U&& u) // NOLINT
: StatusOr(absl::in_place, std::forward<U>(u)) {}
template <typename U = T,
absl::enable_if_t<
internal_statusor::IsConstructionValid<true, T, U, true>::value,
int> = 0>
explicit StatusOr(U&& u ABSL_ATTRIBUTE_LIFETIME_BOUND) // NOLINT
: StatusOr(absl::in_place, std::forward<U>(u)) {}
// StatusOr<T>::ok()
//