C++:Functor
lastmod 2015-03-19created 2015-03-193 edits
An STL functor (Functor), also called a function object, means a function object: an object that can be used like a function with operator().
Syntax
It can be written as follows.
Pros
Functors have the following three advantages.
- A functor can have state. That is, the user can have different states for the same functor at the same time.
- A functor has its own type. In short, it can be used as a type. This means a functor can be used as a template argument, as a type.
- A functor is faster than a function pointer (FunctionPointer).1
Favorite site
- Standard Template Library STL - 6 : Functor (function object)
- Functor (function object)
- Function pointer VS Functor