Any way to get the name of a function?

Daniel Murphy yebblies at nospamgmail.com
Wed Jul 6 21:58:44 PDT 2011


Maybe something like TypeTuple!(foo ,bar) will work.


"Andrej Mitrovic" <andrej.mitrovich at gmail.com> wrote in message 
news:mailman.1452.1310006894.14074.digitalmars-d-learn at puremagic.com...
> 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