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: // this is a functor struct add_x { add_x(int val) : x(val) {} // Constructor int operator()(int y) const { return x + y; } private: int x; }; // Now you can … Read more