std::basic_const_iterator<Iter>::operator 定数イテレータ
From cppreference.com
< cpp | iterator | basic const iterator
| template< /*not-a-const-iterator*/ CI > requires /*constant-iterator*/<CI> && |
(1) | (C++23から) |
| template< /*not-a-const-iterator*/ CI > requires /*constant-iterator*/<CI> && |
(2) | (C++23から) |
内部イテレータ current が明示的または暗黙的に変換可能な、変換された定数イテレータを返します。
CI は、basic_const_iterator の特殊化ではない場合に限り、説明専用コンセプト /*not-a-const-iterator*/ を満たします。
[編集] 戻り値
1)
current2) std::move(
current)[編集] 例
このコードを実行
#include <iterator> #include <ranges> #include <vector> void foo(std::vector<int>::const_iterator) {} int main() { auto v = std::vector<int>(); { // ranges::cbegin below returns vector<int>::const_iterator auto i1 = std::ranges::cbegin(v); foo(i1); // okay } auto t = v | std::views::take_while([](int const x) { return x < 100; }); { // ranges::cbegin below returns basic_const_iterator<vector<int>::iterator> auto i2 = std::ranges::cbegin(t); foo(i2); // error until P2836R1 } }
[編集] 不具合報告
以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。
| DR | 適用対象 | 公開された動作 | 正しい動作 |
|---|---|---|---|
| P2836R1 | C++23 | basic_const_iterator は、その基底となる型の変換可能性に従いません。 |
変換演算子が提供されています。 |