What are C++ functors and their uses?
A functor is pretty much just a class which defines the operator(). That lets you create objects which “look like” a function: There are a couple of nice things about functors. One is that unlike regular functions, they can contain state. The above example creates a function which adds 42 to whatever you give it. … Read more