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.
All the categories of iterators require only those functions that are realizable for a given category in constant time (amortized). Therefore, requirement tables and concept definitions(since C++20) for the iterators do not specify complexity.
[edit] RequirementsThe type It
satisfies LegacyIterator if
It
satisfies CopyConstructible, andIt
satisfies CopyAssignable, andIt
satisfies Destructible, andIt
satisfies Swappable, andvalue_type
,(until C++20) difference_type
, reference
, pointer
, and iterator_category
, andIt
, the following expressions must be valid and have their specified effects:For the definition of std::iterator_traits, the following exposition-only concept is defined.
template<class I>concept __LegacyIterator =
requires(I i)
{
{ *i } -> __Referenceable;
{ ++i } -> std::same_as<I&>;
{ *i++ } -> __Referenceable;
where the exposition-only concept __Referenceable<T> is satisfied if and only if T& is a valid type (in particular, T
must not be void).
Note on terminology: The following table shows the names used on this site and corresponding C++ Standard names (with the same meaning). The "Legacy" (and âCpp17â) prefix emphasizes compatibility with pre-C++20 standards and is used to distinguish these requirements from the new iterator concepts introduced with 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 2437 C++98 *r is required to bereference
not required for output iterators LWG 3420 C++20 the exposition-only concept checks copyable
first copyable
is checked only if the requires-expression yields true [edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4