c++callablecallable-objecterrata

Are pointer to member functions not callable object


I am reading C++ Primer 5th edition and there I came across the following statement:

As a result, unlike ordinary function pointers, a pointer to a member is not a callable object; these pointers do not support the function-call operator.

So my question is: Is the highlighted part correct according to the standard?

My current understanding and intuition are that functionally they behave in the same manner, so a pointer to a member function should also be a callable object(as its name suggest).

Note that I am not asking whether the book is correct in saying that member function pointers do not support the function call operator. Because I already know that that part of the statement is correct. What I am asking is whether the pointer to the member function is a callable object according to the standard.


Solution

  • What i am asking is that whether pointer to member function are callable object according to the standard.

    Yes, a pointer to a member function is a callable object according to the standard.

    From func.def#4:

    A callable object is an object of a callable type.

    And from func.def#3:

    A callable type is a function object type ([function.objects]) or a pointer to member.

    Thus, the highlighted part of the quoted statement that says "a pointer to member is not a callable object" from C++ Primer is incorrect according the standard.