ReturnType and Parameters of Templated function/method

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 13 11:01:25 PDT 2016


On 10/13/2016 07:19 AM, Patric Dexheimer wrote:
> There is a way to capture the return type/parameters of a templated
> function like:
>
> void add(T)(T t){}
> Parameters!add;
>
> Yes, i know that the template don´t have any type until explicitly coded
> like:
> Parameters!(add!int);
>
> Or another solution like getting the string function declaration will be
> enough:
> "void add(T)(T t)"
>
> Like what happens with:
>
> void other_add(int x){}
> writeln( typeof(__traits(getMember, Module, "other_add")).stringof );
> //output: void(int x)

There are several related options in std.traits. What exactly are you 
trying to achieve? Perhaps there is a better way.

Ali



More information about the Digitalmars-d-learn mailing list