std::input_iterator
Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Defined in header <iterator>
|
||
template
<
class I >
concept input_iterator =
|
(since C++20) | |
The input_iterator
concept is a refinement of input_or_output_iterator
, adding the requirement that the referenced values can be read (via indirectly_readable
Iterator concept determination
Definition of this concept is specified via an exposition-only alias template /*ITER_CONCEPT*/.
In order to determine /*ITER_CONCEPT*/<I>, let ITER_TRAITS<I> denote I if the specialization std::iterator_traits<I> is generated from the primary template, or std::iterator_traits<I>
- If ITER_TRAITS<I>::iterator_concept is valid and names a type, /*ITER_CONCEPT*/<I>
- Otherwise, if ITER_TRAITS<I>::iterator_category is valid and names a type, /*ITER_CONCEPT*/<I>
- Otherwise, if std::iterator_traits<I> is generated from the primary template, /*ITER_CONCEPT*/<I> denotes std::random_access_iterator_tag
- Otherwise, /*ITER_CONCEPT*/<I>
Notes
Unlike the LegacyInputIterator requirements, the input_iterator
concept does not require equality_comparable
Example
A minimum input iterator.
#include <cstddef> #include <iterator> struct SimpleInputIterator { using difference_type = std::ptrdiff_t; using value_type = int; int operator*() const; SimpleInputIterator& operator++(); void operator++(int) { ++*this; } }; static_assert(std::input_iterator<SimpleInputIterator>);
See also
(C++20)
|
specifies that objects of a type can be incremented and dereferenced (concept) |
(C++20)
|
specifies that an input_iterator is a forward iterator, supporting equality comparison and multi-pass (concept) |