GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::reverse_iterator::operator=(3) C++ Standard Libary std::reverse_iterator::operator=(3)

std::reverse_iterator::operator= - std::reverse_iterator::operator=


template< class U > (until C++17)
reverse_iterator& operator=( const reverse_iterator<U>& other );
template< class U >
constexpr reverse_iterator& operator=( const reverse_iterator<U>& (since C++17)
other );


The underlying iterator is assigned the value of the underlying iterator of other,
i.e. other.base().


This overload participates in overload resolution only if U is not the
same type as Iter and std::convertible_to<const U&, Iter> and (since C++20)
std::assignable_from<Iter&, const U&> are modeled.


other - iterator adaptor to assign


*this

// Run this code


#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) }; // compilation error:
// incompatible pointer types
std::reverse_iterator<short const*> it2{ nullptr };
it2 = std::rbegin(a3); // OK
// it2 = std::begin(a3); // compilation error: no viable overloaded '='
std::cout << *it2 << '\n';
}


42


Defect reports


The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.


DR Applied to Behavior as published Correct behavior
LWG 3435 C++20 the converting assignment operator was not constrained
constrained


constructor constructs a new iterator adaptor
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.