A LegacyRandomAccessIterator is a LegacyBidirectionalIterator that can be moved to point to any element in constant time.
If a LegacyRandomAccessIterator it originates from a Container, then it's value_type
is the same as the container's, so dereferencing (*it) obtains the container's value_type
.
A pointer to an element of an array satisfies all requirements of LegacyRandomAccessIterator.
[edit] RequirementsThe type It
satisfies LegacyRandomAccessIterator if
It
satisfies LegacyBidirectionalIteratorAnd, given
value_type
, the type denoted by std::iterator_traits<It>::value_typedifference_type
, the type denoted by std::iterator_traits<It>::difference_typereference
, the type denoted by std::iterator_traits<It>::referenceIt
or const ItIt
difference_type
The following expressions must be valid and have their specified effects:
Expression Return type Operational semantics Notes r += nIt&
difference_type m = n;
if (m >= 0) while (m--) ++r;
else while (m++) --r;
return r;
n + a
It
It temp = a;
return temp += n;
It&
return r += -n; The absolute value of n must be within the range of representable values of difference_type
. i - n It
It temp = i;difference_type
return n;
Precondition:
difference_type
such that a + n == bPostcondition:
reference
*(i + n) a < b
meets BooleanTestable
(until C++20)models boolean-testable
Strict total ordering relation:
meets BooleanTestable
(until C++20)models boolean-testable
meets BooleanTestable
(until C++20)models boolean-testable
meets BooleanTestable
(until C++20)models boolean-testable
The above rules imply that LegacyRandomAccessIterator also implements LessThanComparable.
A mutable LegacyRandomAccessIterator is a LegacyRandomAccessIterator that additionally satisfies the LegacyOutputIterator requirements.
[edit] Defect reportsThe following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior LWG 299reference
LWG 448 C++98 the return type of a[n] was required
value_type
the return type is required to be
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