std::counted_iterator<I>::operator=
来自cppreference.com
< cpp | iterator | counted iterator
template <class I2> requires std::assignable_from<I&, const I2&> |
(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)); }
参阅
(C++20) |
构造新的迭代器适配器 (公开成员函数) |