std::ranges::transform_view<V,F>::iterator<Const>::base
From ja.cppreference.net
constexpr const ranges::iterator_t<Base>& base() const & noexcept;
|
(1) | (C++20以降) |
constexpr ranges::iterator_t<Base> base() &&;
|
(2) | (C++20以降) |
基となるイテレータを返します。
1) 基となるイテレータへの参照を返します。
2) 基となるイテレータからムーブ構築した結果を返します。
パラメータ
(なし)
戻り値
1)
基盤となるイテレータへの参照。
2)
基盤となるイテレータからムーブ構築されたイテレータ。
例
このコードを実行
#include <algorithm> #include <iostream> #include <iterator> #include <ranges> int main() { const auto v = { 0, 1, 2, 3, 4 }; auto x2 = [](int x) { return x << 1; }; std::ranges::transform_view tv{ v, x2 }; std::ostream_iterator<int> ostr{ std::cout, " " }; std::ranges::copy(v, ostr), std::cout << '\n'; std::ranges::copy(tv.base(), ostr), std::cout << '\n'; std::ranges::copy(tv, ostr), std::cout << '\n'; }
出力:
0 1 2 3 4 0 1 2 3 4 0 2 4 6 8
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 3533 | C++20 |
baseの
const
&
オーバーロードは基盤イテレータのコピーを返す
|
参照を返す |
| LWG 3593 | C++20 |
baseの
const
&
オーバーロードはnoexceptではない可能性がある
|
noexceptに変更 |