[range.chunk.view.input]

# 25 Ranges library [[ranges]](./#ranges)

## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.chunk.view.input)

### 25.7.29 Chunk view [[range.chunk]](range.chunk#view.input)

#### 25.7.29.2 Class template chunk_view for input ranges [range.chunk.view.input]

[ð](#lib:chunk_view)

namespace std::ranges {template<class I>constexpr I *div-ceil*(I num, I denom) { // *exposition only* I r = num / denom; if (num % denom)++r; return r; }template<[view](range.view#concept:view "25.4.5 Views [range.view]") V>requires [input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]")<V>class chunk_view : public view_interface<chunk_view<V>> { V *base_*; // *exposition only* range_difference_t<V> *n_*; // *exposition only* range_difference_t<V> *remainder_* = 0; // *exposition only**non-propagating-cache*<iterator_t<V>> *current_*; // *exposition only*// [[range.chunk.outer.iter]](range.chunk.outer.iter "25.7.29.3 Class chunk_­view​::​outer-iterator"), class chunk_view​::​*outer-iterator*class *outer-iterator*; // *exposition only*// [[range.chunk.inner.iter]](range.chunk.inner.iter "25.7.29.5 Class chunk_­view​::​inner-iterator"), class chunk_view​::​*inner-iterator*class *inner-iterator*; // *exposition only*public:constexpr explicit chunk_view(V base, range_difference_t<V> n); constexpr V base() const & requires [copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14 Concept copy_­constructible [concept.copyconstructible]")<V> { return *base_*; }constexpr V base() && { return std::move(*base_*); }constexpr *outer-iterator* begin(); constexpr default_sentinel_t end() const noexcept; constexpr auto size() requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<V>; constexpr auto size() const requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<const V>; constexpr auto reserve_hint() requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]")<V>; constexpr auto reserve_hint() const requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]")<const V>; }; template<class R> chunk_view(R&&, range_difference_t<R>) -> chunk_view<views::all_t<R>>;}

[ð](#lib:chunk_view,constructor)

`constexpr explicit chunk_view(V base, range_difference_t<V> n);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L13861)

*Preconditions*: n > 0 is true[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L13865)

*Effects*: Initializes *base_* with std​::​move(base) and*n_* with n[.](#2.sentence-1)

[ð](#lib:begin,chunk_view)

`constexpr outer-iterator begin();
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L13877)

*Effects*: Equivalent to:*current_* = ranges::begin(*base_*);*remainder_* = *n_*;return *outer-iterator*(*this);

[ð](#lib:end,chunk_view)

`constexpr default_sentinel_t end() const noexcept;
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L13893)

*Returns*: default_sentinel[.](#4.sentence-1)

[ð](#lib:size,chunk_view)

`constexpr auto size() requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<V>;
constexpr auto size() const requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<const V>;
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L13905)

*Effects*: Equivalent to:return *to-unsigned-like*(*div-ceil*(ranges::distance(*base_*), *n_*));

[ð](#lib:reserve_hint,chunk_view)

`constexpr auto reserve_hint() requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]")<V>;
constexpr auto reserve_hint() const requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]")<const V>;
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L13920)

*Effects*: Equivalent to:auto s = static_cast<range_difference_t<decltype((*base_*))>>(ranges::reserve_hint(*base_*));return *to-unsigned-like*(*div-ceil*(s, *n_*));
