Boost logo

Boost :

Subject: [boost] [RangeEx] Using istream_range?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2008-10-21 03:54:32

Hi All

I'd really appreciate an example of the use of istream_range from the
Boost.Range library.

I tried this

#include <iostream>
#include <iterator>
#include "boost/range.hpp"
#include "boost/range/istream_range.hpp"
#include "boost/range/algorithm.hpp"

void f( int i )
  std :: cout << i << std :: endl;

int main( )
  typedef std :: istream_iterator< int > in;
  boost :: for_each( boost :: istream_range< in >( std :: cin ), f );
  return 0;

and other variations, but I don't think any of them are right! Do I really
have to specify three template type parameters? The signature of the
template is

namespace boost
    template<class Type, class Elem, class Traits> inline
        range<std::istream_iterator<Type, Elem, Traits> >
    istream_range(std::basic_istream<Elem, Traits>& in)
        return range<std::istream_iterator<Type, Elem, Traits> >(

Thanks, Rob.

Boost list run by bdawes at, gregod at, cpdaniel at, john at