std::contiguous_iterator(3)

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

πŸ’– NAME πŸ’–

okay bestie, this is the page for std::contiguous_iterator(3), straight out of the C++ Standard Libary manual, and the name is literally std::contiguous_iterator β€” that’s it, that’s the icon ✨


🌸 Synopsis 🌸

Defined in header <iterator> πŸŽ€

This whole concept is since C++20, and here’s the exact shape of it:

template< class I >
concept contiguous_iterator =
    std::random_access_iterator<I> &&
    std::derived_from</*ITER_CONCEPT*/<I>,
                      std::contiguous_iterator_tag> &&
    std::is_lvalue_reference_v<std::iter_reference_t<I>> &&
    std::same_as<
        std::iter_value_t<I>,
        std::remove_cvref_t<std::iter_reference_t<I>>
    > &&
    requires(const I& i) {
        { std::to_address(i) } ->
            std::same_as<std::add_pointer_t<std::iter_reference_t<I>>>;
    };

so basically the contiguous_iterator concept refines random_access_iterator by giving you one extra guarantee: the denoted elements are stored contiguously in the memory 🧠✨ no cap.


πŸ¦‹ Notes πŸ¦‹

  • contiguous_iterator is modeled by every pointer type to complete object type πŸ‘‘
  • Iterator types in the standard library that are required to satisfy the LegacyContiguousIterator requirements in C++17 are also required to model contiguous_iterator in C++20 πŸ’…

πŸ‘€ See also πŸ‘€

  • random_access_iterator (C++20) (concept) β€” specifies that a bidirectional_iterator is a random-access iterator, supporting advancement in constant time and subscripting 🌈

okay bye bestie, this page came from http://cppreference.com, dated 2024.06.10, and the manual tag is std::contiguous_iterator(3) β€” slay and stay contiguous πŸ’œπŸ«Ά

πŸ“¦ where this page comes from