The following code using Lambda with vector iterators compiles without complaint:
vector<char> v;
find_if(v.begin(), v.end(), _1 == 'x');
Ditto for this code, which uses istream_iterators:
istream_iterator<char> b1(cin);
istream_iterator<char> e1;
find_if(b1, e1, _1 == 'x');
But the same code with istreambuf_iterators gets rejected:
istreambuf_iterator<char> b2(cin);
istreambuf_iterator<char> e2;
find_if(b2, e2, _1 == 'x');
Error messages from VC8 and gcc 4.1.1 are below. Am I doing something wrong, is
there a bug in Lambda regarding istreambuf_iterators, or is this a restriction
that I didn't see documented somewhere?
Thanks,
Scott
VC8 says:
lambda.cpp
D:\Apps\Microsoft Visual Studio 8\VC\INCLUDE\algorithm(87) : error C2664: 'bool
boost::lambda::lambda_functor<T>::operator ()<char>(
A &) const' : cannot convert parameter 1 from 'char' to 'char &'
[Instantiation traceback omitted]
gcc 4.1.1. says:
stl_algo.h:188: error: no match for call to '(
boost::lambda::lambda_functor<
boost::lambda::lambda_functor_base<
boost::lambda::relational_actionboost::lambda::equal_action
, boost::tuples::tuple<
boost::lambda::lambda_functor<
boost::lambda::placeholder<1>
>, const char
>
>
>
) (char)'
stl_algo.h: In function 'istreambuf_iterator