[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.6 Object 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.6 Object 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.11 Concept 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.12 Concept 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.12 Concept 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.6 Object 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();
