Anakreon wrote:
struct event_locator: public unary_function
{ 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; } and then use bind( has_transaction_with_id, _1, tid ) as the predicate. You can also define hasTransactionWithId as a member of Event and then use bind( &Event::hasTransactionWithId, _1, tid ). 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.