When I say function object, I’m referring to any type with a defined operator().
Actually, that isn't the Standard's formal definition, where a function object is anything that can be called with parentheses. This includes function pointers, classes with overloaded operator(), lambdas (special case of the previous one), and classes that are implicitly convertible to function pointers.
Granted, the latter basically never comes up except in <functional> unit tests.
Most C++ programmers can probably agree that C++11 lambda functions changed their lives.
On the other hand, "lambda function" drives me nuts. Lambdas aren't functions (or std::functions), but such terminology encourages confusion.
Formally, a functor is a mapping between categories that preserves identity morphisms and compositions of morphisms.
No, that's math. Programming is different. Mathematicians consider a "vector" to be different from what we consider it to be.
I know that it isn'toperator(), I was curious what the difference between this and operator() is.
Though now that I think about it, that is pretty obvious... This is actually kind of a cute trick that I might have an application for. I'll have to look into this.
38
u/STL MSVC STL Dev Jan 26 '17
Actually, that isn't the Standard's formal definition, where a function object is anything that can be called with parentheses. This includes function pointers, classes with overloaded operator(), lambdas (special case of the previous one), and classes that are implicitly convertible to function pointers.
Granted, the latter basically never comes up except in <functional> unit tests.
On the other hand, "lambda function" drives me nuts. Lambdas aren't functions (or std::functions), but such terminology encourages confusion.
No, that's math. Programming is different. Mathematicians consider a "vector" to be different from what we consider it to be.