Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading