Export of internal Abseil changes
-- 44ccc0320ffaa2106ba3c6393b5a40c3b4f7b901 by Abseil Team <absl-team@google.com>: Clarify span iterator documentation. PiperOrigin-RevId: 299110584 -- 80d016d8026b8d6904aa0ff2d5e1c3ae27f129bb by Greg Falcon <gfalcon@google.com>: Add Cord::TryFlat(). PiperOrigin-RevId: 298889772 -- da6900203f1e4131d5693cbca157b6dba099bbed by Greg Falcon <gfalcon@google.com>: clang-format cord_test.cc. PiperOrigin-RevId: 298851425 GitOrigin-RevId: 44ccc0320ffaa2106ba3c6393b5a40c3b4f7b901 Change-Id: Ia5394f6fbb473d206726fdd48a00eb07a6acad6a
This commit is contained in:
parent
b19ba96766
commit
cf3a1998e9
5 changed files with 101 additions and 25 deletions
|
|
@ -292,60 +292,74 @@ class Span {
|
|||
|
||||
// Span::front()
|
||||
//
|
||||
// Returns a reference to the first element of this span.
|
||||
// Returns a reference to the first element of this span. The span must not
|
||||
// be empty.
|
||||
constexpr reference front() const noexcept {
|
||||
return ABSL_ASSERT(size() > 0), *data();
|
||||
}
|
||||
|
||||
// Span::back()
|
||||
//
|
||||
// Returns a reference to the last element of this span.
|
||||
// Returns a reference to the last element of this span. The span must not
|
||||
// be empty.
|
||||
constexpr reference back() const noexcept {
|
||||
return ABSL_ASSERT(size() > 0), *(data() + size() - 1);
|
||||
}
|
||||
|
||||
// Span::begin()
|
||||
//
|
||||
// Returns an iterator to the first element of this span.
|
||||
// Returns an iterator pointing to the first element of this span, or `end()`
|
||||
// if the span is empty.
|
||||
constexpr iterator begin() const noexcept { return data(); }
|
||||
|
||||
// Span::cbegin()
|
||||
//
|
||||
// Returns a const iterator to the first element of this span.
|
||||
// Returns a const iterator pointing to the first element of this span, or
|
||||
// `end()` if the span is empty.
|
||||
constexpr const_iterator cbegin() const noexcept { return begin(); }
|
||||
|
||||
// Span::end()
|
||||
//
|
||||
// Returns an iterator to the last element of this span.
|
||||
// Returns an iterator pointing just beyond the last element at the
|
||||
// end of this span. This iterator acts as a placeholder; attempting to
|
||||
// access it results in undefined behavior.
|
||||
constexpr iterator end() const noexcept { return data() + size(); }
|
||||
|
||||
// Span::cend()
|
||||
//
|
||||
// Returns a const iterator to the last element of this span.
|
||||
// Returns a const iterator pointing just beyond the last element at the
|
||||
// end of this span. This iterator acts as a placeholder; attempting to
|
||||
// access it results in undefined behavior.
|
||||
constexpr const_iterator cend() const noexcept { return end(); }
|
||||
|
||||
// Span::rbegin()
|
||||
//
|
||||
// Returns a reverse iterator starting at the last element of this span.
|
||||
// Returns a reverse iterator pointing to the last element at the end of this
|
||||
// span, or `rend()` if the span is empty.
|
||||
constexpr reverse_iterator rbegin() const noexcept {
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
// Span::crbegin()
|
||||
//
|
||||
// Returns a reverse const iterator starting at the last element of this span.
|
||||
// Returns a const reverse iterator pointing to the last element at the end of
|
||||
// this span, or `crend()` if the span is empty.
|
||||
constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); }
|
||||
|
||||
// Span::rend()
|
||||
//
|
||||
// Returns a reverse iterator starting at the first element of this span.
|
||||
// Returns a reverse iterator pointing just before the first element
|
||||
// at the beginning of this span. This pointer acts as a placeholder;
|
||||
// attempting to access its element results in undefined behavior.
|
||||
constexpr reverse_iterator rend() const noexcept {
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
// Span::crend()
|
||||
//
|
||||
// Returns a reverse iterator starting at the first element of this span.
|
||||
// Returns a reverse const iterator pointing just before the first element
|
||||
// at the beginning of this span. This pointer acts as a placeholder;
|
||||
// attempting to access its element results in undefined behavior.
|
||||
constexpr const_reverse_iterator crend() const noexcept { return rend(); }
|
||||
|
||||
// Span mutations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue