![[Dept of Engineering]](http://www.eng.cam.ac.uk/images/house_style/engban-s.gif)
Next: Exercises
Up: Predicates
Previous: Creating predicates
Note: These are sometimes useful but look complicated,
so don't worry if you don't understand them. Examples are
online
.
Adapters are ways to adapt existing predicates - they take and return a
function that we can then use with Standard Library algorithms.
There are 4 types -
- binder
- - to use a 2-arg function object as a 1-arg function.
less is a binary predicate. If we want make a unary predicate
from it we can do
bind2nd(less<int>(),7)).
- member function adapter
- - to use a member function
- pointer to function adapter
- - to use a pointer to a member function
- negator
- - to negate an existing predicate
These can be combined -
... find_if ( ....... not1(bind2nd(ptr_fun(strcmp), "funny")));
Tim Love
2001-07-05