Boost logo

Boost Users :

From: Anakreon (anakreonmejdi_at_[hidden])
Date: 2005-09-29 06:39:21


Peter Dimov wrote:
> Anakreon wrote:
>
>
>>struct event_locator: public unary_function<bool, Event*> {
>> int tId;
>> event_locator(const int tid) : tId(tid) {}
>> const bool operator() (Event* e) {
>>return e->hasTransaction()
>> && e->getTransaction().getId() == tId;
>> }
>>};
>
>
> The best (IMO) approach would be to define
>
> bool has_transaction_with_id( Event /*const?*/ * e, int id )
> {
> return e->hasTransaction() && e->getTransaction().getId() == id;
> }
>
I intended to use lambda in order to avoid declaration of functions or structs
for STL algorithms. If I need to declare the function above then I find no
reason to use lambda at all.

> You can use
>
> bind( &Event::hasTransaction, _1 ) && bind( &Transaction::getId, bind(
> &Event::getTransaction, _1 ) ) == tid
>
> but I'm not sure that you'd want to.
It looks to complex.

Thanks Peter for the response.


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