SImple Boost Lambda problem using arguement as object.

This piece of sample code demonstrates my problem quite well:
#include alist;
while(in!="end")
{
in="";
std::getline(std::cin,in);
alist.push_back(new A(in));
}
std::for_each(alist.begin(),alist.end(),
_1->print_A()); // This is line 30
return 1;
}
----
Using g++ ( 3.??) and the latest boost, I get this error:
main.cpp: In function `int main()':
main.cpp:30: error: base operand of `->' has non-pointer type `const
boost::lambda::lambda_functor

On 7/26/05, Thaddeus Olczyk
This piece of sample code demonstrates my problem quite well:
<snip>
std::for_each(alist.begin(),alist.end(), _1->print_A()); // This is line 30
I think you'll have to use bind(&A::print_A, _1) instead
return 1; } -- Thad
Stuart Dootson

Thaddeus Olczyk wrote:
std::for_each(alist.begin(),alist.end(), _1->print_A()); // This is line 30
I think you have to use a binder here: http://www.boost.org/doc/html/lambda/le_in_details.html#member_functions_as_...
participants (3)
-
Stuart Dootson
-
Thaddeus Olczyk
-
Zeljko Vrba