|
Boost : |
Subject: Re: [boost] [RangeEx] Using istream_range?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2008-10-21 04:38:06
On Tue, Oct 21, 2008 at 9:24 AM, Neil Groves <neil_at_[hidden]>wrote:
> Hi Robert,
>
> You are very welcome. I hope this helps. Let me know how you get on.
>
>
Badly!
IIRC your code was pretty much the first thing I tried, which I have just
tried again and
generated this error message
$ g++ -I.. -o junk.exe junk.cpp
../boost/range/istream_range.hpp: In function
`boost::range<std::istream_iterator<Type, Elem, Traits, ptrdiff_t> > boost
::istream_range(std::basic_istream<_CharT, _Traits>&) [with Type = int, Elem
= char, Traits = std::char_traits<char>]':
junk.cpp:14: instantiated from here
../boost/range/istream_range.hpp:28: error: no matching function for call to
`boost::range<std::istream_iterator<int, ch
ar, std::char_traits<char>, ptrdiff_t> >::range(std::istream_iterator<char,
char, std::char_traits<char>, ptrdiff_t>, st
d::istream_iterator<char, char, std::char_traits<char>, ptrdiff_t>)'
junk.cpp:14: note: candidates are: boost::range<std::istream_iterator<int,
char, std::char_traits<char>, ptrdiff_t> >::r
ange(const boost::range<std::istream_iterator<int, char,
std::char_traits<char>, ptrdiff_t> >&)
../boost/range/range.hpp:162: note: boost::range<Iter>::range(Iter, Iter)
[with Iter = std::istream_iterator<int, char,
std::char_traits<char>, ptrdiff_t>]
../boost/range/range.hpp:155: note: boost::range<Iter>::range() [with Iter
= std::istream_iterator<int, char, std::char
_traits<char>, ptrdiff_t>]
Just in case I'm having a blind moment (not uncommon I might add) I'm also
attaching the full
source, cut and pasted for accuracy
#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( )
{
boost :: for_each( boost :: istream_range< int >( std :: cin ), f );
return 0;
}
If it matters the compiler spec is
$ g++ --version
g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Thanks for your help Neil.
- Rob.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk