The class Istream_iterator<T,Stream> is an input iterator adaptor for the input stream class Stream and value type . It is particularly useful for classes that are similar but not compatible to std::istream.
#include <CGAL/IO/Istream_iterator.h>
|
| |
|
creates an end-of-stream
iterator i. This is a past-the-end iterator, and it is useful
when constructing a range.
| |
|
| |
|
creates an input
iterator i reading from . When reaches end of stream,
this iterator will compare equal to an end-of-stream iterator
created using the default constructor.
| |
i fulfills the requirements for an input iterator.
The following program reads points from a Window_stream until the right mouse button gets clicked.
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/IO/Istream_iterator.h>
#include <CGAL/IO/Window_stream.h>
#include <iostream>
#include <algo>
using namespace CGAL;
typedef Point_2< Cartesian<double> > Point;
typedef Istream_iterator<Point, Window_stream> Iterator;
int main () {
Window_stream window( 512, 512);
window.init( -1.0, 1.0, -1.0);
std::copy( Iterator(window), Iterator(),
std::ostream_iterator<Point>(std::cout,"\n"));
return 0;
}