std::ranges::split_view<V,Pattern>::base
来自cppreference.com
<tbody>
</tbody>
constexpr V base() const& requires std::copy_constructible<V>; |
(1) | (C++20 起) |
constexpr V base() &&; |
(2) | (C++20 起) |
返回底层视图 base_ 的副本。
1) 从底层视图复制构造结果。
2) 从底层视图移动构造结果。
返回值
1) 底层视图的副本。
2) 一个从底层视图移动构造的视图。
示例
运行此代码
#include <iomanip>
#include <iostream>
#include <ranges>
#include <string_view>
int main()
{
constexpr std::string_view keywords{"this throw true try typedef typeid"};
std::ranges::split_view split_view{keywords, ' '};
std::cout << "base() = " << std::quoted(split_view.base()) << "\n"
"子字符串: ";
for (auto split : split_view)
std::cout << std::quoted(std::string_view{split}) << ' ';
std::cout << '\n';
}
输出:
base() = "this throw true try typedef typeid"
子字符串: "this" "throw" "true" "try" "typedef" "typeid"
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
|---|---|---|---|
| LWG 3590 | C++20 | const& 重载额外要求复制赋值有效
|
放宽约束 |
参阅
| 返回底层(适配的)视图的副本 ( std::ranges::lazy_split_view<V,Pattern> 的公开成员函数)
|