std::counted_iterator::operator= - cppreference.com (original) (raw)
| template< class I2 > requires std::assignable_from<I&, const I2&> constexpr counted_iterator& operator=( const counted_iterator<I2>& other ); | | (since C++20) | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------- |
The underlying iterator and length are assigned with those of other.
[edit] Parameters
other | - | iterator adaptor to assign from |
---|
[edit] Return value
*this
[edit] Example
#include #include #include #include int main() { auto a = {3, 1, 4, 1, 5, 9, 2}; std::counted_iterator<std::initializer_list::iterator> p(begin(a), size(a) - 2); std::counted_iterator<std::initializer_list::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)); }