|
|
|
ALegacyInputIterator is aLegacyIterator that can read from the pointed-to element.LegacyInputIterators only guarantee validity for single pass algorithms: once aLegacyInputIteratori has been incremented, all copies of its previous value may be invalidated.
Contents |
Type | Definition |
X | An input iterator type |
T | Thevalue type ofX (i.e.std::iterator_traits<X>::value_type) |
R | std::iterator_traits<X>::reference |
Value | Definition |
i,j | Values of typeX orconst X |
r | A value of typeX& |
Other | Definition |
m | An identifier which possibly denotes a data member or member function |
X
satisfiesLegacyInputIterator if all following conditions are satisfied:
X
satisfiesLegacyIterator.X
satisfiesEqualityComparable.Expression | Type | Semantics | |||||
---|---|---|---|---|---|---|---|
i!= j |
| Precondition | i andj are in thedomain of==. | ||||
Effect | Equivalent to!(i== j). | ||||||
*i | R , convertible toT | Precondition | i isdereferenceable. | ||||
Effect |
| ||||||
i->m | Precondition | i is dereferenceable. | |||||
Effect | Equivalent to(*i).m. | ||||||
++r | X& | Precondition | r is dereferenceable. | ||||
Postcondition |
| ||||||
(void)r++ | Effect | Equivalent to(void)++r. | |||||
*r++ | convertible toT | Effect | Equivalent toT x=*r;++r;return x;. |
The termthe domain of== is used in the ordinary mathematical sense to denote the set of values which can be compared using==. This set can change over time.
Each algorithm places additional requirements on the equality domain for the iterator values it uses. These requirements can be inferred from the uses that algorithm makes of== and!=.
For an input iteratorX
that is not aLegacyForwardIterator,std::iterator_traits<X>::reference does not have to be a reference type: dereferencing an input iterator may return a proxy object orstd::iterator_traits<X>::value_type itself by value (as in the case ofstd::istreambuf_iterator).
ConceptFor the definition ofstd::iterator_traits, the following exposition-only concept is defined.
where the exposition-only concept | (since C++20) |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 98 | C++98 | the return type of*i++ was required to beT | it can be any type convertible toT |
LWG 2114 (P2167R3) | C++98 | convertibility tobool was too weak to reflect the expectation of implementations | requirements strengthened |
(C++20) | specifies that a type is an input iterator, that is, its referenced values can be read and it can be both pre- and post-incremented (concept)[edit] |
Iterator library | provides definitions for iterators, iterator traits, adaptors, and utility functions |