The LegacyIterator requirements describe types that can be used to identify and traverse the elements of a container.
LegacyIterator is the base set of requirements used by other iterator types: LegacyInputIterator, LegacyOutputIterator, LegacyForwardIterator, LegacyBidirectionalIterator, and LegacyRandomAccessIterator. Iterators can be thought of as an abstraction of pointers.
The type It
satisfies LegacyIterator if.
It
satisfies CopyConstructible, and It
satisfies CopyAssignable, and It
satisfies Destructible, and It
satisfy Swappable, and std::iterator_traits<It>
has member typedefs value_type
(until C++20), difference_type
, reference
, pointer
, and iterator_category
, and r
, an lvalue of type It
, the following expressions must be valid and have their specified effects: Expression | Return Type | Precondition |
---|---|---|
*r | unspecified |
r is dereferenceable (see below) |
++r |
It& |
r is incrementable (the behavior of the expression ++r is defined) |
Iterators for which the behavior of the expression *i
is defined are called dereferenceable.
Iterators are not dereferenceable if.
ConceptFor the definition of
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 3420 | C++20 | the exposition-only concept checks copyable first | copyable is checked only if the requires-expression yields true |
(C++20) | specifies that objects of a type can be incremented and dereferenced (concept) |
Iterator library | provides definitions for iterators, iterator traits, adaptors, and utility functions |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/named_req/Iterator