copy(src.begin(), src.end(), dst.begin()); doesn't
work - just iterators can't change container size
#include <iterator>
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)
#include <iterator>
ostream_iterator<T> oi(ostream, delim)
delim is optional, put between successive elements; it has type
const char *
copy(ivec.begin(), ivec.end(), ostream_iterator<int>(cout, " "))
* and ++ are no-ops; = does the write
ostream_iterator<int> osi(cout, " "); *osi++ = 1; // write 1 to std-out osi = 2; // write 2 to std-out
<< must be defined for values of type T
istream_iterator<T> isi(istream);
== against the eof iterator, not .eof().
istream_iterator<int> isi(is);
istream_iterator<int> isi_eof();
while (isi != isi_eof) { /* whatever */ }
std::copy(istream_iterator<int>(cin), istream_iterator<int>(),
back_inserter(ivec));
++ reads the next stream value, returns the next iterator
* returns the most recently read stream value; it doesn't
read a value unless it's the first one
== returns true if two iterators are from the same stream and
both are either eof or not eof
istream_iterator<int> isi1(cin); istream_iterator<int> isi2(cin); cerr << (isi1 == isi2 ? "" : "not ") << "equal\n"; // prints "equal" int i = *isi1++; cerr << (isi1 == isi2 ? "" : "not ") << "equal\n"; // prints "equal"
>> operator must be defined for the value being read
This page last modified on 22 October 2002.