286 lines
9.4 KiB
Markdown
286 lines
9.4 KiB
Markdown
[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.2 Header <iterator> 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.2 Header <array> synopsis [array.syn]"),[<deque>](deque.syn#header:%3cdeque%3e "23.3.4 Header <deque> synopsis [deque.syn]"),[<flat_map>](flat.map.syn#header:%3cflat_map%3e "23.6.7 Header <flat_map> synopsis [flat.map.syn]"),[<flat_set>](flat.set.syn#header:%3cflat_set%3e "23.6.10 Header <flat_set> synopsis [flat.set.syn]"),[<forward_list>](forward.list.syn#header:%3cforward_list%3e "23.3.6 Header <forward_list> synopsis [forward.list.syn]"),[<hive>](hive.syn#header:%3chive%3e "23.3.8 Header <hive> synopsis [hive.syn]"),[<inplace_vector>](inplace.vector.syn#header:%3cinplace_vector%3e "23.3.15 Header <inplace_vector> synopsis [inplace.vector.syn]"),[<list>](list.syn#header:%3clist%3e "23.3.10 Header <list> synopsis [list.syn]"),[<map>](associative.map.syn#header:%3cmap%3e "23.4.2 Header <map> synopsis [associative.map.syn]"),[<regex>](re.syn#header:%3cregex%3e "28.6.3 Header <regex> synopsis [re.syn]"),[<set>](associative.set.syn#header:%3cset%3e "23.4.5 Header <set> synopsis [associative.set.syn]"),[<span>](span.syn#header:%3cspan%3e "23.7.2.1 Header <span> synopsis [span.syn]"),[<string>](string.syn#header:%3cstring%3e "27.4.2 Header <string> synopsis [string.syn]"),[<string_view>](string.view.synop#header:%3cstring_view%3e "27.3.2 Header <string_view> synopsis [string.view.synop]"),[<unordered_map>](unord.map.syn#header:%3cunordered_map%3e "23.5.2 Header <unordered_map> synopsis [unord.map.syn]"),[<unordered_set>](unord.set.syn#header:%3cunordered_set%3e "23.5.5 Header <unordered_set> synopsis [unord.set.syn]"), and[<vector>](vector.syn#header:%3cvector%3e "23.3.12 Header <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)
|