Boost logo

Boost Users :

Subject: Re: [Boost-users] logical operators in lambda
From: Conoscenza Silente (abruzzoforteegentile_at_[hidden])
Date: 2010-04-08 09:17:04


...auch..I figure it out
..I was missing the top header #include "boost/lambda/lambda.hpp"...
Thanks again
Mn

On Thu, Apr 8, 2010 at 2:47 PM, Conoscenza Silente <
abruzzoforteegentile_at_[hidden]> wrote:

> Hi Steven
> sorry to bother you again..but the code doesn't work...I didn't try it
> yesterday when you replied..sorrry for this!
> I read in the documentation that we need some short-circuiting for logical
> operators..
>
> On Wed, Apr 7, 2010 at 5:22 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:
>
>> AMDG
>>
>>
>> Conoscenza Silente wrote:
>>
>>> I am trying to use boost::lambda using logicat operator.
>>> I would like to use it in a STL std::find_if call.
>>>
>>> What I receive is always the same error
>>> error: no match for ‘operator==’ in ‘boost::lambda::<unnamed>::_1 == 13’
>>>
>>> Do you know what I am doing wrong?
>>> Thanks
>>> AFG
>>>
>>> using namespace boost::assign;
>>>
>>> int main( int argc, char** argv ){
>>>
>>> std::vector< int > v;
>>> v += 12,13,14,15;
>>>
>>> bool found_tmp = false;
>>> boost::lambda::var_type< bool >::type found(
>>> boost::lambda::var(found_tmp) );
>>>
>>> std::find_if(
>>> v.begin(),
>>> v.end(),
>>> (
>>> found = ( boost::lambda::_1 == 13 ),
>>> return found
>>> ) );
>>> }
>>>
>>>
>>
>> Don't try to return found inside the lambda expression.
>>
>> Try
>>
>> bool found = std::find_if(v.begin(), v.end(), boost::lambda::_1 == 13) !=
>> v.end();
>>
>> In Christ,
>> Steven Watanabe
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>
>
>



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