The C++ standard defines function objects as:
A function object type is an object type that can be the type of the postfix-expression in a function call. (link)
First I was thinking that function objects were functors, but then I realized that for a function pointer ptr
of type P
(not a function, but a function pointer), std::is_object_v<P>
is true
and can be called with the ptr(Args...)
syntax.
I am right that function pointers are considered as function objects by the standard? And if they are not what part of the definition is not satisfied by function pointers?
Yes, they are. The term "object" in C++ standard does not mean "object" in the OOP sense. An int
is an object.