With a more suitable name, such as "IsOldResult" or "ResultOlderThan", I would say that the final solution will be the most readable, as it is most suitable for prose:
results.remove_if(ResultOlderThan(lifetime));
However, I would probably just go and write a functor if the presented algorithm appeared in several contexts. Writing a 5-line class physically deleted from one site for a single-line call seems to me too wasteful.
Otherwise, the boost :: bind parameter has my vote, as it has the smallest extra fluff between it and std :: bind2nd (_1 and std :: mem_fun_ref, respectively). In addition, boost :: bind works for a larger number of cases in general, for example, in the case when you do not bind only one variable to a function that has only two parameters.
Kaz dragon
source share