Any way to get the name of a function?

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Jul 6 19:47:59 PDT 2011


void foo(){};
void bar(){};

void main()
{
    auto funcs = [&foo, &bar];
}

I'm using this in a foreach loop and invoking each function with some
predefined arguments. But I'd also like to extract the name of each
function because each function does some image processing and then I
save that image to disk.

Basically I want to do:

    foreach (func; funcs)
    {
        func(arguments..);
        writeToFile(func.stringof);
    }

Obviously I can't use arrays since they don't hold any name
information, they just store the pointers.

Can I use tuples somehow? The functions are predefined, I just need to
iterate through all of them and call them and extract their name.


More information about the Digitalmars-d-learn mailing list