How can I express the type of a function in D?

Atila Neves atila.neves at
Fri Feb 1 13:00:14 UTC 2019

On Wednesday, 30 January 2019 at 05:14:20 UTC, Sobaya wrote:
> I want to get a mangled name of a D function by 
> `core.demangle.mangle`, but I'm in trouble because there are no 
> ways to express a type of a function, which is used for a 
> template argument of `mangle`.

There's a way:

int add(int i, int j);
static assert(is(typeof(add) == typeof(*(int function(int, 

Unfortunately there's no dedicated syntax for it, unlike C++. 
Weirdly enough, if you pragma(msg) a function type it prints it 
out in C++ syntax (e.g. `int(int, int)`), but if you type it 
yourself it won't compile.

Then there's this oddity:

More information about the Digitalmars-d-learn mailing list