std::forward_iterator
Min standard notice:
Header: <iterator>
This concept refines std::input_iterator by requiring that I also model std::incrementable (thereby making it suitable for multi-pass algorithms), and guaranteeing that two iterators to the same range can be compared against each other.
# Declarations
template< class I >
concept forward_iterator =
std::input_iterator<I> &&
std::derived_from</*ITER_CONCEPT*/<I>, std::forward_iterator_tag> &&
std::incrementable<I> &&
std::sentinel_for<I, I>;
(since C++20)
# Notes
Unlike the LegacyForwardIterator requirements, the forward_iterator concept does not require dereference to return a reference.
# Example
#include <cstddef>
#include <iterator>
struct SimpleForwardIterator
{
using difference_type = std::ptrdiff_t;
using value_type = int;
int operator*() const;
SimpleForwardIterator& operator++();
SimpleForwardIterator operator++(int)
{
auto tmp = *this;
++*this;
return tmp;
}
bool operator==(const SimpleForwardIterator&) const;
};
static_assert(std::forward_iterator<SimpleForwardIterator>);