February 12, 2011 Get function name at compile time? | ||||
---|---|---|---|---|
| ||||
Is there a way to get a function's name at compile time, for instance as part of a template? Using .stringof doesn't work, and I can't find another way to do it. Any help? class FunctionWrapper(alias func) { string name = func.stringof; } |
February 12, 2011 Re: Get function name at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Eskapp | Sean Eskapp <eatingstaples@gmail.com> wrote:
> Is there a way to get a function's name at compile time, for instance as part
> of a template? Using .stringof doesn't work, and I can't find another way to
> do it. Any help?
>class FunctionWrapper(alias func)
> {
> string name = func.stringof;
> }
This should work (and does for me):
class FunctionWrapper(alias func)
{
string name = __traits(identifier, func);
}
--
Simen
|
Copyright © 1999-2021 by the D Language Foundation