std::ranges::drop_while_view<V,Pred>:: base
From cppreference.net
<
cpp
|
ranges
|
drop while view
C++
Ranges library
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | |||||||||||||||||||
|
|||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
|
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