Is there any way, given the function variable, to get the function name as a string? For example, if I have:
void function(int) func;
Is there any function x () such that I could get:
x(func) == "func";
? I feel this is possible with mixins, but I don't understand how to implement this.
func.stringof
- This is what you need.
You can also make a template:
template Name(alias Func) { enum Name = Func.stringof; } void func() { } pragma(msg, Name!(func)); //prints func()
The simplest solution that comes to my mind:
Your name can be stored in a string, and mixin 'ed if necessary, something like:
mixin
string func_name = "func"; ... int param = 294; mixin(func_name ~ "(" ~ to!string(param) ~ ")");
Source: https://habr.com/ru/post/890987/More articles:how to reject AlertDialog using switches in android sdk - androidDisadvantages and disadvantages of import and import - javauses import some.directory. * worse for performance? - javaSOAP Logging - javaError with RTTI parameters TRttiMethod.Invoke, stdcall and const - rttiC ++: use memset or struct constructor? Which is the fastest? - c ++Using ListView custom adapter with standard Android themes - androidIOS UIBarButtonItem Icons: Facebook / Twitter / Email - iosIP address by domain name - pythonXPath: select the text after the specific tag and before the same next tag - xpathAll Articles