Namespaces
Variants
Views
Actions

cpp/named req/RandomAccessIterator

From cppreference.com
< cpp‎ | named req
Revision as of 23:19, 17 May 2012 by 84.131.173.164 (Talk)

Template:cpp/concept/title Template:cpp/concept/sidebar

An Iterator that can be moved to point to any element in constant time.

A standard pointer satisfies this concept.

Requirements


Expression Return Equivalent expression Notes
i += n It& while ( n > 0 )

   ++i;

  • n can b both positive or negative
  • Constant complexity
i + n It It temp = i;

return i += n;

n + i It i + n
i -= n It& i += -n
i - n It i + -n
n - i It i - n
a[n] convertible to T *(a + n)
a < b bool (a-b) > 0 Strict total ordering relation:
  • !(a < a)
  • if a < b then !(b < a)
  • if a < b and b < c then a < c
  • a < b or b < a or a == b
    (exactly one of the expression is true)
a > b bool b < a
a >= b bool !(a < b)
a <= b bool !(a > b)

Table Notes

  • It is the type implementing this concept
  • i, a, b are objects of type It
  • n is an integer of type difference_type
  • T is the iterator's value type