std::ranges::drop_view<V>::base
ja.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