Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
iterator
advance
back_inserter
distance
front_inserter
inserter
iterator
iterator_traits
iterator categories:
BidirectionalIterator
ForwardIterator
InputIterator
OutputIterator
RandomAccessIterator
predefined iterators:
back_insert_iterator
front_insert_iterator
insert_iterator
istreambuf_iterator
istream_iterator
ostreambuf_iterator
ostream_iterator
reverse_iterator
reverse_iterator
reverse_iterator::reverse_iterator
member functions:
base
operator*
operator+
operator++
operator+=
operator-
operator--
operator-=
operator->
operator[]


operator->

public member function
pointer operator->() const;

Dereference iterator

Returns the element pointed by the iterator in order to access one of its members.

The iterator must point to some object (must not be null pointing) in order to be dereferenciable.

Parameters

none

Return value

A pointer to the element pointed by the iterator.
pointer is a member type defined as an alias of the base iterator's own pointer type.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// reverse_iterator::operator-> example
#include <iostream>
#include <iterator>
#include <map>
#include <string>
using namespace std;
int main () {
  map<int,string> numbers;
  numbers.insert (make_pair(1,"one"));
  numbers.insert (make_pair(2,"two"));
  numbers.insert (make_pair(3,"three"));
  typedef map<int,string>::iterator map_iter;
  reverse_iterator<map_iter> rev_end (numbers.begin());
  reverse_iterator<map_iter> rev_iterator (numbers.end());
  for ( ; rev_iterator != rev_end ; ++rev_iterator)
    cout << rev_iterator->first << " " << rev_iterator->second << "\n";
  return 0;
}


Output:

3 three
2 two
1 one

See also