Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

Tim tim.dlang at t-online.de
Sat Oct 23 19:03:41 UTC 2021


On Saturday, 23 October 2021 at 18:56:48 UTC, Simon wrote:
> And I tried to use your suggestion like this:
>
> enum OUTPUT_REPRO_CASE(alias func = __traits(parent, {})) = 
> "build the actual code stuff with"~fullyQualifiedName!func~" 
> and so on";
>
> Which doesn't work. In that case func seems to become the 
> parent namespace. If I substitute fullyQualifiedName!func with 
> fullyQualifiedName!(__traits(parent, {}))) I get a circular 
> dependecy error.
>
> How do I have to use this exactly?

This seems to work:

import std.traits, std.stdio;
enum OUTPUT_REPRO_CASE = q{
     string name = fullyQualifiedName!(__traits(parent, {}));
     writeln(name);
};
void test()
{
     mixin(OUTPUT_REPRO_CASE);
}
void main()
{
     test();
}



More information about the Digitalmars-d-learn mailing list