std::reverse_iterator<Iter>:: operator=
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
|
reverse_iterator::operator=
|
||||
| Non-member functions | ||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++14)
|
|
template
<
class
U
>
reverse_iterator & operator = ( const reverse_iterator < U > & other ) ; |
(constexpr начиная с C++17) | |
Присваивает
other.
current
в
current
.
|
Эта перегрузка участвует в разрешении перегрузки только если std:: is_same_v < U, Iter > равно false и оба условия std:: convertible_to < const U & , Iter > и std:: assignable_from < Iter & , const U & > выполняются. |
(since C++20) |
Содержание |
Параметры
| other | - | адаптер итератора для присваивания |
Возвращаемое значение
* this
Пример
#include <iostream> #include <iterator> int main() { const int a1[]{0, 1, 2}; int a2[]{0, 1, 2, 3}; short a3[]{40, 41, 42}; std::reverse_iterator<const int*> it1{std::crbegin(a1)}; it1 = std::reverse_iterator<int*>{std::rbegin(a2)}; // OK // it1 = std::reverse_iterator<short*>{std::rbegin(a3)}; // Ошибка компиляции: // несовместимые типы указателей std::reverse_iterator<const short*> it2{nullptr}; it2 = std::rbegin(a3); // OK // it2 = std::begin(a3); // Ошибка компиляции: нет подходящей перегрузки operator= std::cout << *it2 << '\n'; }
Вывод:
42
Отчеты о дефектах
Следующие отчеты об изменениях поведения, влияющие на дефекты, были применены ретроактивно к ранее опубликованным стандартам C++.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 280 | C++98 | heterogeneous assignment was not allowed | allowed |
| LWG 3435 | C++20 | the converting assignment operator was not constrained | constrained |
Смотрите также
создаёт новый
reverse_iterator
(public member function) |