ConceptC++ Concept Web

Concept RandomAccessIterator

concept RandomAccessIterator<typename X> : BidirectionalIterator, LessThanComparable {
  X& operator+=(X&, difference_type);
  X  operator+ (X, difference_type);
  X  operator+ (difference_type, X);
  X& operator-=(X&, difference_type);
  X  operator- (X, difference_type);
 
  difference_type operator-(X, X);
  reference operator[](X, difference_type);
 
  bool operator>=(X, X);
  bool operator>(X, X);
  bool operator<=(X, X);
};

Where Defined

#include <iterator>

Description

Random access iterators allow algorithms to move iterators an arbitrary number of steps forward or backward in constant time.

X& operator+=(X&, difference_type); 

Effects: equalivalent to

{ difference_type m = n; 
if (m >= 0) while (m--) ++r; 
else while (m++) --r; 
return r; } 
X operator+(X a, difference_type n); 
X operator+(difference_type n, X a); 

Effects: equivalent to

{ X tmp = a; 
return tmp += n; } 

Postcondition: a + n == n + a

X& operator-=(X& r, difference_type n); 

Returns: r += -n

X operator-(X, difference_type); 

Effects: equivalent to

{ X tmp = a; 
return tmp -= n; } 
difference_type operator-(X a, X b); 

Precondition: there exists a value n of difference_type such that a + n == b.

Effects: b == a + (b - a)

Returns: (a < b) ? distance(a,b) : -distance(b,a)

bool operator>(X, X); 

Effects: > is a total ordering relation opposite to <.

Pointers to constant values are random access iterators:

template<typename T> concept_map RandomAccessIterator<const T*> {
  typedef T value_type;
  typedef std::ptrdiff_t difference_type;
  typedef const T& reference;
  typedef const T* pointer;
};