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

138 lines
4.1 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.

[range.subrange.access]
# 25 Ranges library [[ranges]](./#ranges)
## 25.5 Range utilities [[range.utility]](range.utility#range.subrange.access)
### 25.5.4 Sub-ranges [[range.subrange]](range.subrange#access)
#### 25.5.4.3 Accessors [range.subrange.access]
[🔗](#lib:begin,subrange)
`constexpr I begin() const requires [copyable](concepts.object#concept:copyable "18.6Object concepts[concepts.object]")<I>;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2100)
*Effects*: Equivalent to: return *begin_*;
[🔗](#lib:begin,subrange_)
`constexpr I begin() requires (![copyable](concepts.object#concept:copyable "18.6Object concepts[concepts.object]")<I>);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2111)
*Effects*: Equivalent to: return std::move(*begin_*);
[🔗](#lib:end,subrange)
`constexpr S end() const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2122)
*Effects*: Equivalent to: return *end_*;
[🔗](#lib:empty,subrange)
`constexpr bool empty() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2133)
*Effects*: Equivalent to: return *begin_* == *end_*;
[🔗](#lib:size,subrange)
`constexpr make-unsigned-like-t<iter_difference_t<I>> size() const
requires (K == subrange_kind::sized);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2145)
*Effects*:
- [(5.1)](#5.1)
If *StoreSize* is true, equivalent to: return *size_*;
- [(5.2)](#5.2)
Otherwise, equivalent to: return *to-unsigned-like*(*end_* - *begin_*);
[🔗](#lib:next,subrange)
`constexpr subrange next(iter_difference_t<I> n = 1) const &
requires [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11Concept forward_­iterator[iterator.concept.forward]")<I>;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2160)
*Effects*: Equivalent to:auto tmp = *this;
tmp.advance(n);return tmp;
[🔗](#lib:next,subrange_)
`constexpr subrange next(iter_difference_t<I> n = 1) &&;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2176)
*Effects*: Equivalent to:advance(n);return std::move(*this);
[🔗](#lib:prev,subrange)
`constexpr subrange prev(iter_difference_t<I> n = 1) const
requires [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12Concept bidirectional_­iterator[iterator.concept.bidir]")<I>;
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2192)
*Effects*: Equivalent to:auto tmp = *this;
tmp.advance(-n);return tmp;
[🔗](#lib:advance,subrange)
`constexpr subrange& advance(iter_difference_t<I> n);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2208)
*Effects*: Equivalent to:if constexpr ([bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12Concept bidirectional_­iterator[iterator.concept.bidir]")<I>) {if (n < 0) { ranges::advance(*begin_*, n); if constexpr (*StoreSize*)*size_* += *to-unsigned-like*(-n); return *this; }}auto d = n - ranges::advance(*begin_*, n, *end_*);if constexpr (*StoreSize*)*size_* -= *to-unsigned-like*(d);return *this;
[🔗](#lib:get,subrange)
`template<size_t N, class I, class S, subrange_kind K>
requires ((N == 0 && [copyable](concepts.object#concept:copyable "18.6Object concepts[concepts.object]")<I>) || N == 1)
constexpr auto get(const subrange<I, S, K>& r);
template<size_t N, class I, class S, subrange_kind K>
requires (N < 2)
constexpr auto get(subrange<I, S, K>&& r);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2239)
*Effects*: Equivalent to:if constexpr (N == 0)return r.begin();elsereturn r.end();