std::ranges::lazy_split_view<V,Pattern>::base
来自 zh.cppreference.net
constexpr V base() const& requires std::copy_constructible<V>;
|
(1) | (C++20 起) |
constexpr V base() &&;
|
(2) | (C++20 起) |
返回底层视图的副本base_。
1) 从底层视图
base_复制构造结果。2) 从底层视图
base_移动构造结果。返回值
底层视图
base_
的一个副本。
示例
运行此代码
#include <iostream> #include <ranges> #include <string_view> void print(std::string_view rem, auto const& r, std::string_view post = "\n") { for (std::cout << rem; auto const& e : r) std::cout << e; std::cout << post; } int main() { constexpr std::string_view keywords{ "this,..throw,..true,..try,.." }; constexpr std::string_view pattern{",.."}; constexpr std::ranges::lazy_split_view lazy_split_view{keywords, pattern}; print("base() = [", lazy_split_view.base(), "]\n" "substrings: "); for (auto const& split: lazy_split_view) print("[", split, "] "); }
输出:
base() = [this,..throw,..true,..try,..] substrings: [this] [throw] [true] [try] []
参见
|
返回底层(适配后)视图的副本
(
std::ranges::split_view<V,Pattern>
的公开成员函数)
|