std::ranges::common_view<V>::begin
来自cppreference.com
| |
(1) | (C++20 起) |
| |
(2) | (C++20 起) |
1) 返回指向
common_view 首元素的迭代器,即:
2) 同 (1),但
V 为 const 限定。返回值
指向底层视图起始的迭代器。
示例
运行此代码
#include <iostream>
#include <numeric>
#include <ranges>
#include <string_view>
int main()
{
constexpr auto common = std::views::iota(1)
| std::views::take(3)
| std::views::common
;
for (int i{}; int e : common)
std::cout << (i++ ? " + " : "") << e;
std::cout << " = " << std::accumulate(common.begin(), common.end(), 0) << '\n';
}
输出:
1 + 2 + 3 = 6
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
|---|---|---|---|
| LWG 4012 | C++20 | 非 const 重载缺少对简单视图的检查 | 已添加 |
参阅
| 返回 指向末尾的迭代器 (公开成员函数) | |
(C++20) |
返回指向范围起始的迭代器 (定制点对象) |
(C++20) |
返回指示范围结尾的哨位 (定制点对象) |