[range.drop.view]

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

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

### 25.7.12 Drop view [[range.drop]](range.drop#view)

#### 25.7.12.2 Class template drop_view [range.drop.view]

[ð](#lib:drop_view)

namespace std::ranges {template<[view](range.view#concept:view "25.4.5 Views [range.view]") V>class drop_view : public view_interface<drop_view<V>> {public: drop_view() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<V> = default; constexpr explicit drop_view(V base, range_difference_t<V> count); 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 auto begin()requires (!([*simple-view*](range.utility.helpers#concept:simple-view "25.5.2 Helper concepts [range.utility.helpers]")<V> &&[random_access_range](range.refinements#concept:random_access_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>)); constexpr auto begin() constrequires [random_access_range](range.refinements#concept:random_access_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>; constexpr auto end() requires (![*simple-view*](range.utility.helpers#concept:simple-view "25.5.2 Helper concepts [range.utility.helpers]")<V>){ return ranges::end(*base_*); }constexpr auto end() const requires [range](range.range#concept:range "25.4.2 Ranges [range.range]")<const V>{ return ranges::end(*base_*); }constexpr auto size() requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<V> {const auto s = ranges::size(*base_*); const auto c = static_cast<decltype(s)>(*count_*); return s < c ? 0 : s - c; }constexpr auto size() const requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<const V> {const auto s = ranges::size(*base_*); const auto c = static_cast<decltype(s)>(*count_*); return s < c ? 0 : s - c; }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> {const auto s = static_cast<range_difference_t<V>>(ranges::reserve_hint(*base_*)); return *to-unsigned-like*(s < *count_* ? 0 : s - *count_*); }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> {const auto s = static_cast<range_difference_t<const V>>(ranges::reserve_hint(*base_*)); return *to-unsigned-like*(s < *count_* ? 0 : s - *count_*); }private: V *base_* = V(); // *exposition only* range_difference_t<V> *count_* = 0; // *exposition only*}; template<class R> drop_view(R&&, range_difference_t<R>) -> drop_view<views::all_t<R>>;}

[ð](#lib:drop_view,constructor)

`constexpr explicit drop_view(V base, range_difference_t<V> count);
`

[1](#1)

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

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

[2](#2)

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

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

[ð](#lib:begin,drop_view)

`constexpr auto begin()
  requires (!([simple-view](range.utility.helpers#concept:simple-view "25.5.2 Helper concepts [range.utility.helpers]")<V> &&
              [random_access_range](range.refinements#concept:random_access_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>));
constexpr auto begin() const
  requires [random_access_range](range.refinements#concept:random_access_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>;
`

[3](#3)

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

*Returns*: ranges​::​next(ranges​::​begin(*base_*), *count_*, ranges​::​end(*base_*))[.](#3.sentence-1)

[4](#4)

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

*Remarks*: In order to provide the amortized constant-time complexity required
by the [range](range.range#concept:range "25.4.2 Ranges [range.range]") concept
when drop_view models [forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]"),
the first overload caches the result within the drop_view for use on subsequent calls[.](#4.sentence-1)

[*Note [1](#note-1)*:

Without this,
applying a reverse_view over a drop_view would have quadratic iteration complexity[.](#4.sentence-2)

â *end note*]
