[range.drop.while.view]

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

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

### 25.7.13 Drop while view [[range.drop.while]](range.drop.while#view)

#### 25.7.13.2 Class template drop_while_view [range.drop.while.view]

[ð](#lib:drop_while_view)

namespace std::ranges {template<[view](range.view#concept:view "25.4.5 Views [range.view]") V, class Pred>requires [input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]")<V> && is_object_v<Pred> &&[indirect_unary_predicate](indirectcallable.indirectinvocable#concept:indirect_unary_predicate "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<const Pred, iterator_t<V>>class drop_while_view : public view_interface<drop_while_view<V, Pred>> {public: drop_while_view() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<V> && [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<Pred> = default; constexpr explicit drop_while_view(V base, Pred pred); 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 const Pred& pred() const; constexpr auto begin(); constexpr auto end() { return ranges::end(*base_*); }private: V *base_* = V(); // *exposition only**movable-box*<Pred> *pred_*; // *exposition only*}; template<class R, class Pred> drop_while_view(R&&, Pred) -> drop_while_view<views::all_t<R>, Pred>;}

[ð](#lib:drop_while_view,constructor)

`constexpr explicit drop_while_view(V base, Pred pred);
`

[1](#1)

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

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

[ð](#lib:pred,drop_while_view)

`constexpr const Pred& pred() const;
`

[2](#2)

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

*Effects*: Equivalent to: return **pred_*;

[ð](#lib:begin,drop_while_view)

`constexpr auto begin();
`

[3](#3)

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

*Preconditions*: *pred_*.has_value() is true[.](#3.sentence-1)

[4](#4)

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

*Returns*: ranges​::​find_if_not(*base_*, cref(**pred_*))[.](#4.sentence-1)

[5](#5)

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

*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_while_view models [forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]"),
the first call caches the result within the drop_while_view for use on subsequent calls[.](#5.sentence-1)

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

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

â *end note*]
