| 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 since C++17) | |
Assignsother.current tocurrent.
This overload participates in overload resolution only ifstd::is_same_v<U, Iter> isfalse and bothstd::convertible_to<const U&, Iter> andstd::assignable_from<Iter&,const U&> are modeled. | (since C++20) |
Contents |
| other | - | iterator adaptor to assign |
*this
#include <iostream>#include <iterator> int main(){constint a1[]{0,1,2};int a2[]{0,1,2,3};short a3[]{40,41,42}; std::reverse_iterator<constint*> it1{std::crbegin(a1)}; it1=std::reverse_iterator<int*>{std::rbegin(a2)};// OK// it1 = std::reverse_iterator<short*>{std::rbegin(a3)}; // Compilation error:// incompatible pointer typesstd::reverse_iterator<constshort*> it2{nullptr}; it2=std::rbegin(a3);// OK// it2 = std::begin(a3); // Compilation error: no viable operator= overloadstd::cout<<*it2<<'\n';}
Output:
42
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| 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 |
constructs a newreverse_iterator(public member function)[edit] |