Merits of function reference as first class pointer

Happy distancing holiday (as well as Jewish Passover) to all of my, non-existing, audience.

In C++, a function name is a somewhat strange object. It can be assigned, without conversion, to a variable of type “pointer to function”, but it is not, itself, a pointer to function. Trying to take its size results in an error saying “ISO C++ forbids applying ‘sizeof’ to an expression of function type”, and passing -fpermissive to g++ results in a sizeof of 1 (i.e. - no size) rather than the size of a pointer.

In all other respects, however, a function name is precisely a pointer to function. Consider the following program:

int func();
constexpr int (*pfunc)() = func;

int main() {

Looking at the resulting machine code shows that the use of func and of pfunc is exactly the same. It is also true for how the linker sees the two. For all intents and purposes, func is a pointer to function.

Which brings me to Practical. I want to make a function name be of type “pointer to function rvalue”.

Which is where I present it to my theoretical audience: discuss.

Essentially, what I’m suggesting here is to treat the name of the function as a “pointer to function” literal.