Why functor
Function pointer is not flexible, it is difficult to use with other components STL
Adapter
The interface of a class into another class interface, so that classes had not because of incompatible interfaces and cooperation, can work together
The STL adapter
function adapter
Functor interface change, typically be embodied by a combination of the function
container adapter
Changes in container interfaces, such as queue and stack is actually modified from the deque
iterator adapter
Iterator interface changes, such as
- assign general transition insert iterator iterator to be inserted, as a function of the code copy
- back_inserter(Container& x)
- front_inserter(Container& x)
- inserter(Container& x, Iterator i)
- reverse iterator to the direction of travel of the reversal of the general iterator
- iostream iterator The iterator binding to a target iostream
- istream iterator as operator ++ will become operator >>
to sum up
Imitation function overloading operator ()
iterator overloaded operator *, operator ++ pointer habitual behavior such as
containers and iterators body of the adapter is a template
reference
- STL source code analysis Chapter 8