| ||||||||||||||||||||||
| Range primitives | |||||||
| |||||||
| Range concepts | |||||||||||||||||||
| |||||||||||||||||||
| Range factories | |||||||||
| |||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper items | |||||||||||||||||
| |||||||||||||||||
drop_view() requiresstd::default_initializable<V>=default; | (1) | (since C++20) |
constexprexplicit drop_view( V base,ranges::range_difference_t<V> count); | (2) | (since C++20) |
Constructs adrop_view.
base_ and initializes the countcount_ to0. After construction,base() returns a copy ofV() andsize() equals to the size of the underlying view.base_ withstd::move(base) and the countcount_ withcount. After construction,base() returns a copy ofbase andsize() returnsranges::size(base)- count if the size ofbase is not less thancount, or0 otherwise.| base | - | the underlying view |
| count | - | number of elements to skip |
#include <algorithm>#include <array>#include <iostream>#include <iterator>#include <ranges> int main(){constexprstd::array hi{'H','e','l','l','o',',',' ','C','+','+','2','0'}; std::ranges::for_each(hi,[](constchar c){std::cout<< c;});std::cout<<'\n'; constexprauto n=std::distance(hi.cbegin(), std::ranges::find(hi,'C')); auto cxx= std::ranges::drop_view{hi, n}; std::ranges::for_each(cxx,[](constchar c){std::cout<< c;});std::cout<<'\n';}
Output:
Hello, C++20C++20
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 3714 (P2711R1) | C++20 | the multi-parameter constructor was not explicit | made explicit |