Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-01-30 22:39:09


Gottlob Frege wrote:
> On 1/30/07, Meryl Silverburgh <silverburgh.meryl_at_[hidden]> wrote:
>> Hi,
>>
>> I am trying to Boost::for_each function to set a local variable if
>> all elements in this is DEFAULT type.
>>
>> Here is my code, but I don't know how to implement the last part of
>> the if_then call.
>>
>> boolean rtnValue = false;
>>
>
> bool rtnValue = true; // assume true
>
>> for_each(mylist.begin(), mylist.end(), if_then(
>> bind(&ListItem::getType, _1) == DEFAULT, set the local value to true
>> if true if all of them are DEFAULT type ));
>>
> bind(&ListItem::getType, _1) != DEFAULT, set the local value to
> false));

bool rtnValue = find_if( mylist.begin(), mylist.end(),
    bind(&ListItem::getType, _1) != DEFAULT ) == mylist.end();


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