Namespaces
Variants
Views
Actions

C++ named requirements: LegacyInputIterator

From cppreference.com
< cpp‎ | named req
 
 
C++ named requirements
 

An LegacyInputIterator is an LegacyIterator that can read from the pointed-to element. LegacyInputIterators only guarantee validity for single pass algorithms: once an LegacyInputIterator i has been incremented, all copies of its previous value may be invalidated.

[edit] Requirements

The type It satisfies LegacyInputIterator if

And, given

The following expressions must be valid and have their specified effects

Expression Return Equivalent expression Notes
i != j contextually convertible to bool !(i == j) Precondition: (i, j) is in the domain of ==.
*i reference, convertible to value_type If i == j and (i, j) is in the domain of == then this is equivalent to *j.

Precondition: i is dereferenceable.

The expression (void)*i, *i is equivalent to *i.

i->m (*i).m Precondition: i is dereferenceable.
++i It&

Precondition: i is dereferenceable.

Postcondition: i is dereferenceable or i is past-the-end.

Postcondition: Any copies of the previous value of i are no longer required to be either dereferenceable or to be in the domain of ==.

(void)i++ (void)++i
*i++ convertible to value_type value_type x = *i;

++i;

return x;

[edit] Notes

"in the domain of ==" means equality comparison is defined between the two iterator values. For input iterators, equality comparison does not need to be defined for all values, and the set of the values in the domain of == may change over time.

The reference type for an input iterator that is not also a LegacyForwardIterator does not have to be a reference type: dereferencing an input iterator may return a proxy object or value_type itself by value (as in the case of std::istreambuf_iterator).

[edit] See also

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]