std::ranges::drop_view<V>::base
来自 zh.cppreference.net
constexpr V base() const& requires std::copy_constructible<V>;
|
(1) | (自C++20起) |
constexpr V base() &&;
|
(2) | (自C++20起) |
返回底层视图的副本。
1) 从底层视图复制构造结果
base_.2) 从底层视图移动构造结果
base_.返回值
底层(适配后)视图
base_
的副本。
示例
运行此代码
#include <iostream> #include <ranges> namespace stq { void println(auto, const auto& v) { for (const auto& e : v) std::cout << e << ' '; std::cout << '\n'; } } int main() { static constexpr int a[]{1, 2, 3, 4, 5}; constexpr auto view = a | std::views::drop(2); stq::println("{}", view); const auto base = view.base(); stq::println("{}", base); }
输出:
3 4 5 1 2 3 4 5