Using stateful functors

For another example posts on functors (function objects) see here. A functor is an instance of a C++ class that has the operator() defined. One big advantage of functors is that when you define the operator() in C++ classes you not only get objects that can act like functions, but can also store state as …

Continue reading ‘Using stateful functors’ »

Using Function Objects (Functors) in STL / C++

Generically, function objects (or functors) are class instances whose member function operator() has been defined. This member function allows the object to be used with the same syntax as a regular function call, and therefore its type can be used as template parameter when a generic function type is expected. So why not just use …

Continue reading ‘Using Function Objects (Functors) in STL / C++’ »