Scroll to navigation

std::counted_iterator::operator=(3) C++ Standard Libary std::counted_iterator::operator=(3)

NAME

std::counted_iterator::operator= - std::counted_iterator::operator=

Synopsis


template< class I2 >


requires std::assignable_from<I&, const I2&> (since C++20)


constexpr counted_iterator& operator=( const counted_iterator<I2>&
other );


The underlying iterator and length are assigned with those of other.

Parameters


other - iterator adaptor to assign from

Return value


*this

Example

// Run this code


#include <algorithm>
#include <cassert>
#include <initializer_list>
#include <iterator>


int main()
{
auto a = {3, 1, 4, 1, 5, 9, 2};
std::counted_iterator<std::initializer_list<int>::iterator> p(begin(a), size(a) - 2);
std::counted_iterator<std::initializer_list<int>::iterator> q;
assert(q.count() == 0);
assert(q.count() != p.count());
q = p;
assert(q.count() == p.count());
assert(std::ranges::equal(p, std::default_sentinel, q, std::default_sentinel));
}

See also


constructor constructs a new iterator adaptor
(C++20) (public member function)

2024.06.10 http://cppreference.com