Files
2025-10-25 03:02:53 +03:00

286 lines
9.4 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.

[iterator.range]
# 24 Iterators library [[iterators]](./#iterators)
## 24.7 Range access [iterator.range]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7229)
In addition to being available via inclusion of the [<iterator>](iterator.synopsis#header:%3citerator%3e "24.2Header <iterator>&nbsp;synopsis[iterator.synopsis]") header,
the function templates in [iterator.range] are available when any of the following
headers are included:[<array>](array.syn#header:%3carray%3e "23.3.2Header <array> synopsis[array.syn]"),[<deque>](deque.syn#header:%3cdeque%3e "23.3.4Header <deque> synopsis[deque.syn]"),[<flat_map>](flat.map.syn#header:%3cflat_map%3e "23.6.7Header <flat_­map> synopsis[flat.map.syn]"),[<flat_set>](flat.set.syn#header:%3cflat_set%3e "23.6.10Header <flat_­set> synopsis[flat.set.syn]"),[<forward_list>](forward.list.syn#header:%3cforward_list%3e "23.3.6Header <forward_­list> synopsis[forward.list.syn]"),[<hive>](hive.syn#header:%3chive%3e "23.3.8Header <hive> synopsis[hive.syn]"),[<inplace_vector>](inplace.vector.syn#header:%3cinplace_vector%3e "23.3.15Header <inplace_­vector> synopsis[inplace.vector.syn]"),[<list>](list.syn#header:%3clist%3e "23.3.10Header <list> synopsis[list.syn]"),[<map>](associative.map.syn#header:%3cmap%3e "23.4.2Header <map> synopsis[associative.map.syn]"),[<regex>](re.syn#header:%3cregex%3e "28.6.3Header <regex> synopsis[re.syn]"),[<set>](associative.set.syn#header:%3cset%3e "23.4.5Header <set> synopsis[associative.set.syn]"),[<span>](span.syn#header:%3cspan%3e "23.7.2.1Header <span> synopsis[span.syn]"),[<string>](string.syn#header:%3cstring%3e "27.4.2Header <string> synopsis[string.syn]"),[<string_view>](string.view.synop#header:%3cstring_view%3e "27.3.2Header <string_­view> synopsis[string.view.synop]"),[<unordered_map>](unord.map.syn#header:%3cunordered_map%3e "23.5.2Header <unordered_­map> synopsis[unord.map.syn]"),[<unordered_set>](unord.set.syn#header:%3cunordered_set%3e "23.5.5Header <unordered_­set> synopsis[unord.set.syn]"), and[<vector>](vector.syn#header:%3cvector%3e "23.3.12Header <vector> synopsis[vector.syn]")[.](#1.sentence-1)
[🔗](#lib:begin(C&))
`template<class C> constexpr auto begin(C& c) -> decltype(c.begin());
template<class C> constexpr auto begin(const C& c) -> decltype(c.begin());
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7258)
*Returns*: c.begin()[.](#2.sentence-1)
[🔗](#lib:end(C&))
`template<class C> constexpr auto end(C& c) -> decltype(c.end());
template<class C> constexpr auto end(const C& c) -> decltype(c.end());
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7270)
*Returns*: c.end()[.](#3.sentence-1)
[🔗](#lib:begin(T_(&)%5bN%5d))
`template<class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7281)
*Returns*: array[.](#4.sentence-1)
[🔗](#lib:end(T_(&)%5bN%5d))
`template<class T, size_t N> constexpr T* end(T (&array)[N]) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7292)
*Returns*: array + N[.](#5.sentence-1)
[🔗](#lib:cbegin(const_C&))
`template<class C> constexpr auto cbegin(const C& c) noexcept(noexcept(std::begin(c)))
-> decltype(std::begin(c));
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7303)
*Returns*: std::begin(c)[.](#6.sentence-1)
[🔗](#lib:cend(const_C&))
`template<class C> constexpr auto cend(const C& c) noexcept(noexcept(std::end(c)))
-> decltype(std::end(c));
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7314)
*Returns*: std::end(c)[.](#7.sentence-1)
[🔗](#lib:rbegin(C&))
`template<class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin());
template<class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin());
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7325)
*Returns*: c.rbegin()[.](#8.sentence-1)
[🔗](#lib:rend(C&))
`template<class C> constexpr auto rend(C& c) -> decltype(c.rend());
template<class C> constexpr auto rend(const C& c) -> decltype(c.rend());
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7336)
*Returns*: c.rend()[.](#9.sentence-1)
[🔗](#lib:rbegin(T_(&array)%5bN%5d))
`template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7346)
*Returns*: reverse_iterator<T*>(array + N)[.](#10.sentence-1)
[🔗](#lib:rend(T_(&array)%5bN%5d))
`template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]);
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7356)
*Returns*: reverse_iterator<T*>(array)[.](#11.sentence-1)
[🔗](#lib:rbegin(initializer_list%3cE%3e))
`template<class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7366)
*Returns*: reverse_iterator<const E*>(il.end())[.](#12.sentence-1)
[🔗](#lib:rend(initializer_list%3cE%3e))
`template<class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il);
`
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7376)
*Returns*: reverse_iterator<const E*>(il.begin())[.](#13.sentence-1)
[🔗](#lib:crbegin(const_C&_c))
`template<class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c));
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7386)
*Returns*: std::rbegin(c)[.](#14.sentence-1)
[🔗](#lib:crend(const_C&_c))
`template<class C> constexpr auto crend(const C& c) -> decltype(std::rend(c));
`
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7396)
*Returns*: std::rend(c)[.](#15.sentence-1)
[🔗](#lib:size(C&_c))
`template<class C> constexpr auto size(const C& c) -> decltype(c.size());
`
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7406)
*Returns*: c.size()[.](#16.sentence-1)
[🔗](#lib:size(T_(&array)%5bN%5d))
`template<class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept;
`
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7416)
*Returns*: N[.](#17.sentence-1)
[🔗](#lib:ssize(C&_c))
`template<class C> constexpr auto ssize(const C& c)
-> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>;
`
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7427)
*Effects*: Equivalent to:return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>>(c.size());
[🔗](#lib:ssize(T_(&array)%5bN%5d))
`template<class T, ptrdiff_t N> constexpr ptrdiff_t ssize(const T (&array)[N]) noexcept;
`
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7440)
*Returns*: N[.](#19.sentence-1)
[🔗](#lib:empty(C&_c))
`template<class C> constexpr auto empty(const C& c) -> decltype(c.empty());
`
[20](#20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7450)
*Returns*: c.empty()[.](#20.sentence-1)
[🔗](#lib:empty(T_(&array)%5bN%5d))
`template<class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept;
`
[21](#21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7460)
*Returns*: false[.](#21.sentence-1)
[🔗](#lib:empty(initializer_list%3cE%3e))
`template<class E> constexpr bool empty(initializer_list<E> il) noexcept;
`
[22](#22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7470)
*Returns*: il.size() == 0[.](#22.sentence-1)
[🔗](#lib:data(C&_c))
`template<class C> constexpr auto data(C& c) -> decltype(c.data());
template<class C> constexpr auto data(const C& c) -> decltype(c.data());
`
[23](#23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7481)
*Returns*: c.data()[.](#23.sentence-1)
[🔗](#lib:data(T_(&array)%5bN%5d))
`template<class T, size_t N> constexpr T* data(T (&array)[N]) noexcept;
`
[24](#24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7491)
*Returns*: array[.](#24.sentence-1)
[🔗](#lib:data(initializer_list%3cE%3e))
`template<class E> constexpr const E* data(initializer_list<E> il) noexcept;
`
[25](#25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7501)
*Returns*: il.begin()[.](#25.sentence-1)