[range.drop.view] (original) (raw)
25 Ranges library [ranges]
25.7 Range adaptors [range.adaptors]
25.7.12 Drop view [range.drop]
25.7.12.2 Class template drop_view [range.drop.view]
namespace std::ranges { template<view V> class drop_view : public view_interface<drop_view<V>> { public: drop_view() requires default_initializable<V> = default;constexpr explicit drop_view(V base, range_difference_t<V> count);constexpr V base() const & requires copy_constructible<V> { return base_; } constexpr V base() && { return std::move(base_); } constexpr auto begin() requires (!(simple-view<V> && random_access_range<const V> && sized_range<const V>));constexpr auto begin() const requires random_access_range<const V> && sized_range<const V>;constexpr auto end() requires (<V>) { return ranges::end(base_); } constexpr auto end() const requires range<const V> { return ranges::end(base_); } constexpr auto size() requires sized_range<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<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<V> { const auto s = static_cast<range_difference_t<cV>>(ranges::reserve_hint(base_));return to-unsigned-like(s < _count__ ? 0 : s - _count__);} constexpr auto reserve_hint() const requires approximately_sized_range<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(); range_difference_t<V> count_ = 0; };template<class R> drop_view(R&&, range_difference_t<R>) -> drop_view<views::all_t<R>>;}
constexpr explicit drop_view(V base, range_difference_t<V> count);
Preconditions: count >= 0 is true.
Effects: Initializes base_ with std::move(base) and_count__ with count.
Returns: ranges::next(ranges::begin(base_), count_, ranges::end(base_)).
Remarks: In order to provide the amortized constant-time complexity required by the range concept when drop_view models forward_range, the first overload caches the result within the drop_viewfor use on subsequent calls.
[Note 1:
Without this, applying a reverse_view over a drop_viewwould have quadratic iteration complexity.
— _end note_]