|
Boost Users : |
From: Boris (boriss_at_[hidden])
Date: 2007-03-13 10:30:16
On Tue, 13 Mar 2007 00:21:36 +0200, Rodolfo Lima <rodolfo_at_[hidden]>
wrote:
>> // Why doesn't this compile ...
>> std::for_each(from.begin(), from.end(), if_then((_1 ->* &sample::odd) ==
>> false, std::cout << _1));
>
> IMO it should be &1->*&sample::odd
>
> The ->* operator expects a pointer in its left side. Since & has higher
> priority than ->*, it suffices to add & to _l and it'll work.
I played around some more and even removed the comparison with false. But
neither this ...
std::for_each(from.begin(), from.end(), if_then(boost::lambda::_1 ->*
&sample::odd, std::cout << boost::lambda::_1));
... nor that ...
std::for_each(from.begin(), from.end(), if_then(&boost::lambda::_1 ->*
&sample::odd, std::cout << boost::lambda::_1));
compiles. VC8++ complains about error C2451: conditional expression of
type 'boost::lambda::detail::member_pointer_caller<RET,A,B>' is illegal.
Everything works though with boost::lambda::bind. Why I don't know. From
the documentation ->* looks like a more readable shortcut than
boost::lambda::bind. There seem to be some limitations though (or does it
depend on the compiler)?
Boris
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net