Internal migration PiperOrigin-RevId: 945892864 Change-Id: I597c871f42e8121d05dae4fbad7b78e79b30274d
diff --git a/absl/types/any_span.h b/absl/types/any_span.h index bca47bc..04e64dc 100644 --- a/absl/types/any_span.h +++ b/absl/types/any_span.h
@@ -702,29 +702,22 @@ // subspan, but both the container and transform must remain valid. // pos must be non-negative and <= size(). // len must be non-negative and <= size() - pos, or equal to npos. - // If len == npos, the subspan continues till the end of this span. - - constexpr AnySpan subspan(size_type pos, size_type len) const { + // If len==npos, the subspan continues till the end of this span. + constexpr AnySpan subspan(size_type pos, size_type len = npos) const { const size_t this_size = size(); if (len == AnySpan<T>::npos) { len = this_size - pos; } absl::base_internal::HardeningAssertLE(pos, this_size); - absl::base_internal::HardeningAssertLE(len, - static_cast<size_type>(this_size - - pos)); + absl::base_internal::HardeningAssertLE( + len, static_cast<size_type>(this_size - pos)); return AnySpan<T>(getter_.Offset(pos), len); } - constexpr AnySpan subspan(size_type pos) const { - absl::base_internal::HardeningAssertLE(pos, size()); - return AnySpan(getter_.Offset(pos), size() - pos); - } - - // Returns a `AnySpan` containing first `len` elements. Parameter `len` - // must be non-negative and <= size(). + // Returns a `AnySpan` containing first `len` elements. Parameter `len` must + // be non-negative and <= size(). constexpr AnySpan first(size_type len) const { - absl::base_internal::HardeningAssert(len != AnySpan<T>::npos); + absl::base_internal::HardeningAssert(len != npos); return subspan(0, len); }