Scroll to navigation

std::input_or_output_iterator(3) C++ Standard Libary std::input_or_output_iterator(3)

NAME

std::input_or_output_iterator - std::input_or_output_iterator

Synopsis


Defined in header <iterator>
template< class I >


concept input_or_output_iterator =
requires(I i) { (since C++20)
{ *i } -> /*can-reference*/;
} &&


std::weakly_incrementable<I>;


The input_or_output_iterator concept forms the basis of the iterator concept
taxonomy; every iterator type satisfies the input_or_output_iterator requirements.


The exposition-only concept /*can-reference*/ is satisfied if and only if the type
is referenceable (in particular, not void).


This section is incomplete
Reason: Is *i required to be equality-preserving?

Notes


input_or_output_iterator itself only specifies operations for dereferencing and
incrementing an iterator. Most algorithms will require additional operations, for
example:


* comparing iterators with sentinels (see sentinel_for);
* reading values from an iterator (see indirectly_readable and input_iterator);
* writing values to an iterator (see indirectly_writable and output_iterator);
* a richer set of iterator movements (see forward_iterator,
bidirectional_iterator, random_access_iterator).


Unlike the LegacyIterator requirements, the input_or_output_iterator concept does
not require copyability.

Example


A minimum iterator.


#include <cstddef>
#include <iterator>


struct SimpleIterator
{
using difference_type = std::ptrdiff_t;


int operator*();


SimpleIterator& operator++();
void operator++(int) { ++*this; }
};


static_assert(std::input_or_output_iterator<SimpleIterator>);

Category:


* Todo with reason

2024.06.10 http://cppreference.com