std::ranges::drop_while_view<V,Pred>::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_ から結果をムーブ構築します。パラメータ
(なし)
戻り値
基になるビューのコピー。
例
このコードを実行
#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` は `data` を参照 std::ranges::reverse(base); //< `data` を間接的に変更 print(data.cbegin(), data.cend()); }
出力:
1 2 3 4 5 3 4 5 5 4 3 2 1