An adapter is a type of functor that allows a method or a pointer to a function to be used as an argument to algorithms [1].
Most adapters can be found in the header file functional.
There are four types of adapters [1]:
- Binder: allows a two-argument function object to be used as a single-argument function by binding one argument to a value
- Member function adapter: allows a member function to be used as an argument to algorithms
- Pointer to function adapter: allows a pointer-to-function to be used as an argument to algorithms
- Negater: allows to express the opposite of a predicate
One can distinguish STL and Boost adapters by their namespace: All STL objects are in namespace std. All Boost objects are in namespace boost.
- [1] Bjarne Stroustrup. The C++ Programming Language (3rd edition). 1997. ISBN: 0-201-88954-4. Chapter 18.4.4: 'A member function adapter allows a member function to be used as an argument to algorithms. A pointer to function adapter allows a pointer to a function to be used as an argument to algorithms.'