++
++itr
- advance the iterator itr
to the next element and
return the newly advanced iterator
itr++
- remember the iterator itr
, advance itr
to the
next element and return the old itr
==
and !=
- tests if two iterators
refer to the same value or two different values
*itr
- return the value being referenced by the iterator
itr
*
because it can only appear on the
right-hand side of an assignment statement - if itr
is an
input iterator, than
i = *itr;
is correct because *
is being used to read
itr
*itr = i;
is incorrect because *
is being used to write
itr
*itr
- return the location being referenced by the
iterator itr
*
because it can only appear on the
left-hand side of an assignment statement - if itr
is an
output iterator, than
i = *itr;
is incorrect because *
is being used to read
itr
*itr = i;
is correct because *
is being used to write
itr
--
- for moving the iterator back to the previous
value
x = *(itr + 5)
, x = itr[5]
+=
and -=
for jumping
around
itr += 5
cnt = end_itr - start_itr - 1;
<
operator - does one iterator refer to a value earlier in
the sequence than another iterator
copy(src.begin(), src.end(), dst.begin());
doesn't
work - just iterators can't change container size
back_insert_iterator<typename T> bi(C)
back_inserter(c)
.push_back(
V)
C must support push_back()
front_insert_iterator<typename T> fi(C)
front_inserter(c)
C.push_front(v)
C must support push_front()
insert_iterator<typename T> ii(c, p)
inserter(c, p)
C.insert(p, v)
ostream_iter<T> oi(ostream, delim)
delim
is optional, put between successive elements; it has type
const char *
copy(ivec.begin(), ivec.end(), ostream_iter<int>(cout, " "))
<<
must be defined for values of type T
istream_iter<T> ii_eof()
istream_iter<T> ii(istream)
copy(istream_iter<int>(cin), istream_iter<int>(), back_inserter(ivec))
>>
operator must be defined for the value being read
This page last modified on 1 November 2001.