c++functionc++11type-traitsfunction-object

Are function pointers function objects in C++?


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?


Solution

  • Yes, they are. The term "object" in C++ standard does not mean "object" in the OOP sense. An int is an object.