std::ranges::drop_view<V>::drop_view
来自cppreference.com
| |
(1) | (C++20 起) |
| |
(2) | (C++20 起) |
构造 drop_view。
2) 以
std::move(base) 初始化底层视图 base_ 并以 count 初始化计数 count_。构造后 base() 返回 base 的副本而 size() 在 base 的大小不小于 count 时返回 ranges::size(base) - count,否则返回 0。参数
| base | - | 底层视图 |
| count | - | 要跳过的元素数 |
示例
Run this code
#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';
}
输出:
Hello, C++20
C++20
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
|---|---|---|---|
| LWG 3714 (P2711R1) |
C++20 | 多参数构造函数不是显式的 | 改成显式的 |