Getting symbol of current function?
Simen Kjærås
simen.kjaras at gmail.com
Fri Dec 7 11:16:20 UTC 2018
On Friday, 7 December 2018 at 10:51:38 UTC, Tomer Filiba wrote:
> Is there some clever way to get the *symbol* of the current
> function, given overloads? I want to log the current function's
> arguments, but __FUNCTION__ et al only give me a name, which
> resolves to the first overload. For instance,
>
> void f(int x) {
> pragma(msg, "overload1",
> Parameters!(mixin(__FUNCTION__)));
> }
> void f(int x, int y) {
> pragma(msg, "overload2",
> Parameters!(mixin(__FUNCTION__)));
> }
>
> shows
> overload1(int)
> overload2(int)
>
> It would be awesome to have something like __FUNCTION_SYM__ or
> so, which references the actual symbol.
What you're looking for is __traits(parent, {}).
mixin(__FUNCTION__) gives you the overload set by that name, not
just a single function.
--
Simen
More information about the Digitalmars-d
mailing list