std::bidirectional_iterator(3)

NAME
std::bidirectional_iterator - std::bidirectional_iterator

Synopsis
   Defined in header <iterator>
   template< class I >
       concept bidirectional_iterator =
           std::forward_iterator<I> &&
           std::derived_from</*ITER_CONCEPT*/<I>,
   std::bidirectional_iterator_tag> && (since C++20)
           requires(I i) {
               { --i } -> std::same_as<I&>;
               { i-- } -> std::same_as<I>;
           };
   The concept bidirectional_iterator refines forward_iterator by adding the ability to
   move an iterator backward.

Notes
   Unlike the LegacyBidirectionalIterator requirements, the bidirectional_iterator
   concept does not require dereference to return an lvalue.

Example
   A minimum bidirectional iterator.
 #include <cstddef>
 #include <iterator>
 struct SimpleBidiIterator
 {
     using difference_type = std::ptrdiff_t;
     using value_type = int;
     int operator*() const;
     SimpleBidiIterator& operator++();
     SimpleBidiIterator operator++(int)
     {
         auto tmp = *this;
         ++*this;
         return tmp;
     }
     SimpleBidiIterator& operator--();
     SimpleBidiIterator operator--(int)
     {
         auto tmp = *this;
         --*this;
         return tmp;
     }
     bool operator==(const SimpleBidiIterator&) const;
 };
 static_assert(std::bidirectional_iterator<SimpleBidiIterator>);

See also
   forward_iterator specifies that an input_iterator is a forward iterator,
   (C++20) supporting equality comparison and multi-pass
                        (concept)
                        specifies that a bidirectional_iterator is a random-access
   random_access_iterator iterator, supporting advancement in constant time and
   (C++20) subscripting
                        (concept)