std::counted_iterator<I>::operator=

来自cppreference.com
 
 
迭代器库
迭代器概念
迭代器原语
算法概念与工具
间接可调用概念
常用算法要求
工具
迭代器适配器
流迭代器
迭代器定制点
迭代器操作
(C++11)
(C++11)
范围访问
(C++11)(C++14)
(C++11)(C++14)
(C++17)(C++20)
(C++14)(C++14)
(C++14)(C++14)
(C++17)
(C++17)
 
 
template <class I2>

  requires std::assignable_from<I&, const I2&>

constexpr counted_iterator& operator=( const counted_iterator<I2>& other );
(C++20 起)

other 赋值底层迭代器与长度

参数

other - 作为复制来源的迭代器适配器

返回值

*this

示例

#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));
}

参阅

构造新的迭代器适配器
(公开成员函数)