std::counte...::operator=(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay bestie, this is std::counte...::operator=(3) from the C++ Standard Libary manual β€” yes, the header spells it like that, and honestly? iconic typo behavior πŸ’€.

std::counted_iterator::operator= β€” std::counted_iterator::operator= (that's literally the whole name, periodt ✨).


🌸 Synopsis 🌸

Here's the signature, bestie β€” C++20 core, with a lil requires clause doing its vibe check:

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 β€” it returns itself, main character energy fr fr πŸ‘‘.


πŸ”₯ Example πŸ”₯

Run this code, bestie:

        // 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) πŸ¦‹

okay that's the whole page, bestie 🫢. It's from http://cppreference.com, dated 2024.06.10, and the page is std::counte...::operator=(3) β€” go assign some iterators responsibly πŸ’…βœ¨.

πŸ“¦ where this page comes from