Difference between revisions of "cpp/named req/RandomAccessIterator"
From cppreference.com
(+mutable) |
m (r2.7.3) (Robot: Adding de, es, fr, it, ja, pt, ru, zh) |
||
Line 71: | Line 71: | ||
A {{tt|mutable RandomAccessiterator}} is a {{tt|BidirectionalIterator}} that additionally satisfies the {{concept|OutputIterator}} requirements. | A {{tt|mutable RandomAccessiterator}} is a {{tt|BidirectionalIterator}} that additionally satisfies the {{concept|OutputIterator}} requirements. | ||
+ | |||
+ | [[de:cpp/concept/RandomAccessIterator]] | ||
+ | [[es:cpp/concept/RandomAccessIterator]] | ||
+ | [[fr:cpp/concept/RandomAccessIterator]] | ||
+ | [[it:cpp/concept/RandomAccessIterator]] | ||
+ | [[ja:cpp/concept/RandomAccessIterator]] | ||
+ | [[pt:cpp/concept/RandomAccessIterator]] | ||
+ | [[ru:cpp/concept/RandomAccessIterator]] | ||
+ | [[zh:cpp/concept/RandomAccessIterator]] |
Revision as of 13:58, 2 November 2012
Template:cpp/concept/title Template:cpp/concept/navbar
A RandomAccessIterator
is a Template:concept that can be moved to point to any element in constant time.
A standard pointer is an example of a type that satisfies this concept.
Requirements
In addition to the above requirement, for a type It
to be an RandomAccessIterator
, instances a
, b
, i
, and r
of It
must:
Expression | Return | Equivalent expression | Notes |
---|---|---|---|
r += n | It& | if(n>=0) while(n--) ++r; |
|
i + n | It | It temp = i; return temp += n; |
|
n + i | It | i + n | |
r -= n | It& | return r += -n; | |
i - n | It | It temp = i; return temp -= n; |
|
n - i | It | i - n | |
b - a | difference |
n |
returns n such that a+n==b
|
i[n] | convertible to reference |
*(i + n) | |
a < b | contextually convertible to bool | b - a > 0 | Strict total ordering relation:
|
a > b | contextually convertible to bool | b < a | Total ordering relation opposite to a < b |
a >= b | contextually convertible to bool | !(a < b) | |
a <= b | contextually convertible to bool | !(a > b) |
Table Notes
It
is the type implementing this conceptT
is the type std::iterator_traits<It>::value_typereference
is the type std::iterator_traits<It>::referencedifference
is the type std::iterator_traits<It>::difference_typei
,a
,b
are objects of typeIt
orconst It
r
is a value of typeIt&
n
is an integer of typedifference
The above rules imply that RandomAccessIterator also implements Template:concept.
A mutable RandomAccessiterator
is a BidirectionalIterator
that additionally satisfies the Template:concept requirements.