[range.enumerate.view]

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

## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.enumerate.view)

### 25.7.24 Enumerate view [[range.enumerate]](range.enumerate#view)

#### 25.7.24.2 Class template enumerate_view [range.enumerate.view]

[ð](#lib:enumerate_view)

namespace std::ranges {template<[view](range.view#concept:view "25.4.5 Views [range.view]") V>requires [*range-with-movable-references*](range.utility.helpers#concept:range-with-movable-references "25.5.2 Helper concepts [range.utility.helpers]")<V>class enumerate_view : public view_interface<enumerate_view<V>> { V *base_* = V(); // *exposition only*// [[range.enumerate.iterator]](range.enumerate.iterator "25.7.24.3 Class template enumerate_­view​::​iterator"), class template enumerate_view​::​*iterator*template<bool Const>class *iterator*; // *exposition only*// [[range.enumerate.sentinel]](range.enumerate.sentinel "25.7.24.4 Class template enumerate_­view​::​sentinel"), class template enumerate_view​::​*sentinel*template<bool Const>class *sentinel*; // *exposition only*public:constexpr enumerate_view() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<V> = default; constexpr explicit enumerate_view(V base); constexpr auto begin() requires (![*simple-view*](range.utility.helpers#concept:simple-view "25.5.2 Helper concepts [range.utility.helpers]")<V>){ return *iterator*<false>(ranges::begin(*base_*), 0); }constexpr auto begin() const requires [*range-with-movable-references*](range.utility.helpers#concept:range-with-movable-references "25.5.2 Helper concepts [range.utility.helpers]")<const V>{ return *iterator*<true>(ranges::begin(*base_*), 0); }constexpr auto end() requires (![*simple-view*](range.utility.helpers#concept:simple-view "25.5.2 Helper concepts [range.utility.helpers]")<V>) {if constexpr ([forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]")<V> && [common_range](range.refinements#concept:common_range "25.4.6 Other range refinements [range.refinements]")<V> && [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<V>)return *iterator*<false>(ranges::end(*base_*), ranges::distance(*base_*)); elsereturn *sentinel*<false>(ranges::end(*base_*)); }constexpr auto end() const requires [*range-with-movable-references*](range.utility.helpers#concept:range-with-movable-references "25.5.2 Helper concepts [range.utility.helpers]")<const V> {if constexpr ([forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]")<const V> && [common_range](range.refinements#concept:common_range "25.4.6 Other range refinements [range.refinements]")<const V> && [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<const V>)return *iterator*<true>(ranges::end(*base_*), ranges::distance(*base_*)); elsereturn *sentinel*<true>(ranges::end(*base_*)); }constexpr auto size() requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<V>{ return ranges::size(*base_*); }constexpr auto size() const requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<const V>{ return ranges::size(*base_*); }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>{ return ranges::reserve_hint(*base_*); }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>{ return ranges::reserve_hint(*base_*); }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_*); }}; template<class R> enumerate_view(R&&) -> enumerate_view<views::all_t<R>>;}

[ð](#lib:enumerate_view,constructor)

`constexpr explicit enumerate_view(V base);
`

[1](#1)

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

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