Files
cppdraft_translate/cppdraft/span/iterators.md
2025-10-25 03:02:53 +03:00

83 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[span.iterators]
# 23 Containers library [[containers]](./#containers)
## 23.7 Views [[views]](views#span.iterators)
### 23.7.2 Contiguous access [[views.contiguous]](views.contiguous#span.iterators)
#### 23.7.2.2 Class template span [[views.span]](views.span#span.iterators)
#### 23.7.2.2.7 Iterator support [span.iterators]
[🔗](#lib:iterator,span)
`using iterator = implementation-defined;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20893)
The type
models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14Concept contiguous_­iterator[iterator.concept.contiguous]") ([[iterator.concept.contiguous]](iterator.concept.contiguous "24.3.4.14Concept contiguous_­iterator")),
meets the *Cpp17RandomAccessIterator* requirements ([[random.access.iterators]](random.access.iterators "24.3.5.7Random access iterators")),
and
meets the requirements for
constexpr iterators ([[iterator.requirements.general]](iterator.requirements.general "24.3.1General")),
whose value type is value_type and
whose reference type is reference[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20904)
All requirements on container iterators ([[container.reqmts]](container.reqmts "23.2.2.2Container requirements")) apply tospan::iterator as well[.](#2.sentence-1)
[🔗](#lib:span,begin)
`constexpr iterator begin() const noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20915)
*Returns*: An iterator referring to the first element in the span[.](#3.sentence-1)
If empty() is true, then it returns the
same value as end()[.](#3.sentence-2)
[🔗](#lib:span,end)
`constexpr iterator end() const noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20928)
*Returns*: An iterator which is the past-the-end value[.](#4.sentence-1)
[🔗](#lib:span,rbegin)
`constexpr reverse_iterator rbegin() const noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20939)
*Effects*: Equivalent to: return reverse_iterator(end());
[🔗](#lib:span,rend)
`constexpr reverse_iterator rend() const noexcept;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20950)
*Effects*: Equivalent to: return reverse_iterator(begin());