std::ranges...ional_range(3)

πŸ“¦
version 2024.07.05 Β· 3 versions
, in nixpkgs unstable, opensuse-leap 16.0

std::ranges::bidirectional_range(3) πŸ’…

okay bestie, welcome to the C++ Standard Libary manual β€” section 3, the std::ranges::bidirectional_range page. no cap, we're in range-concept territory and it's lowkey iconic. πŸ¦‹


✨ NAME ✨

std::ranges::bidirectional_range - std::ranges::bidirectional_range β€” yes, the NAME line is literally the same thing twice, and honestly? main character energy. 🫢


πŸ¦‹ Synopsis πŸ¦‹

Defined in header <ranges>.

(since C++20) bestie, this one's a C++20 baby. ✨

template< class T >
concept bidirectional_range =
    ranges::forward_range<T> &&
    std::bidirectional_iterator<ranges::iterator_t<T>>;

The bidirectional_range concept is a refinement of range for which ranges::begin returns a model of bidirectional_iterator. that's the whole vibe: ranges::begin has to give you a bidirectional_iterator model, periodt. πŸ”₯


πŸŽ€ Example πŸŽ€

here's the demo, bestie β€” run this code if you want, it's giving valid concept checks. πŸ’–

       // Run this code

        #include <forward_list>
        #include <list>
        #include <ranges>
        #include <set>
        #include <unordered_set>

        int main()
        {
            static_assert(
                    std::ranges::bidirectional_range<std::set<int>> and
                not std::ranges::bidirectional_range<std::unordered_set<int>>
       and
                    std::ranges::bidirectional_range<std::list<int>> and
                not std::ranges::bidirectional_range<std::forward_list<int>>
            );
        }

πŸ’œ See also πŸ’œ

  • ranges::forward_range (C++20) β€” specifies a range whose iterator type satisfies forward_iterator (concept)
  • ranges::random_access_range (C++20) β€” specifies a range whose iterator type satisfies random_access_iterator (concept)

okay that's the page, bestie πŸŽ€ source: http://cppreference.com, version/date: 2024.06.10, and it's the std::ranges::bidirectional_range(3) page. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from