How do I the temlate parameter name as string?

Neia Neutuladh neia at ikeran.org
Tue Nov 27 04:35:56 UTC 2018


On Tue, 27 Nov 2018 02:00:44 +0000, PacMan wrote:
> f is defined as:
> 
>> void f(T)(T t, string p)
>> if(is(T == A) || is(T == B))
>>{
>>	// ...
>>}
> 
> my goal is get "p" as string.

`f` is a template that generates functions. Before you instantiate that 
template, the function doesn't exist, so there's no function to get 
parameters from.

You can get the parameter names of any instantiation of that template, 
such as:

    assert(ParameterIdentifierTuple!(f!A)[1] == "p");


More information about the Digitalmars-d-learn mailing list