Let's take a simple functor
class LessThan {
public:
explicit LessThan (int in ) : val(in) {}
bool operator() (int param) const {
return param < val;
}
private:
int val;
};
which I can use like this for example -
vector<int> myVector = factory();
size_t count = count_if(begin(myVector), end(myVector), LessThan(10));
My understanding of the terminology surrounding functors is that the class LessThan
is a functor. i.e. it is a type, not an object. i.e it is abstract, not concrete.
So, what do we call LessThan(10)
? Here, we are creating an object by instantiating the LessThan
functor type. So, do we call it a functor object? But, functors are function objects. So, LessThan(10)
is a function object object??
Isn't that absurd?