Search code examples
c++c++11using-declaration

What's the using equivalent of a function typedef?


How can I use the new1 using keyword to declare a function type?

I know how I can use it to declare a function pointer type. For example, the following typedef:

typedef int (*int_to_int)(int);

seems equivalent to the following using declaration:

using int_to_int = int (*)(int);

How do I do the same for the following non-pointer typedef:

typedef int (int_to_intf)(int);

My "removing the typedef name and putting it after using" algorithm doesn't work:

using int_to_intf_u = int ()(int);  // nope, doesn't compile

A goldbolt link.


1 At least for those poor souls like me who still define "new" as "introduced in C++11".


Solution

  • It's just int(int). To get the abstract declarator, just remove the variable name from an actual declaration. You would declare int f(int);, so the abstract declarator should be int(int).