drop_view() requires std::default_initializable<V> = default; | (1) | (since C++20) |
constexpr drop_view( V base, ranges::range_difference_t<V> count ); | (2) | (since C++20) |
Constructs a drop_view.
0. After construction, base() returns a copy of V() and size() equals to the size of the underlying view.std::move(base) and the count with count. After construction, base() returns a copy of base and size() returns ranges::size(base) - count if the size of base is not less than count, or 0 otherwise.| base | - | the underlying view |
| count | - | number of elements to skip. |
#include <algorithm>
#include <array>
#include <iostream>
#include <iterator>
#include <ranges>
int main()
{
constexpr std::array hi{ 'H','e','l','l','o',',',' ','C','+','+','2','0' };
std::ranges::for_each(hi, [](const char c){ std::cout << c; });
std::cout << '\n';
constexpr auto n = std::distance(hi.cbegin(), std::ranges::find(hi, 'C'));
auto cxx = std::ranges::drop_view{ hi, n };
std::ranges::for_each(cxx, [](const char c){ std::cout << c; });
std::cout << '\n';
}Output:
Hello, C++20 C++20
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/ranges/drop_view/drop_view