std::ranges::drop_while_view<V,Pred>::base
From cppreference.com
< cpp | ranges | drop while view
| constexpr V base() const& requires std::copy_constructible<V>; |
(1) | (C++20以降) |
| constexpr V base() &&; |
(2) | (C++20以降) |
基底ビューのコピーを返します。
1) 基底ビュー
base_をコピー構築して結果を取得します。2) 基底ビュー
base_から結果をムーブ構築します。[編集] パラメータ
(なし)
[編集] 戻り値
基底ビューのコピー。
[編集] 例
このコードを実行
#include <algorithm> #include <array> #include <iostream> #include <ranges> void print(auto first, auto last) { for (; first != last; ++first) std::cout << *first << ' '; std::cout << '\n'; } int main() { std::array data{1, 2, 3, 4, 5}; print(data.cbegin(), data.cend()); auto func = [](int x) { return x < 3; }; auto view = std::ranges::drop_while_view{data, func}; print(view.begin(), view.end()); auto base = view.base(); // `base` refers to the `data` std::ranges::reverse(base); //< changes `data` indirectly print(data.cbegin(), data.cend()); }
出力
1 2 3 4 5 3 4 5 5 4 3 2 1