Compile-time reflection and templates
    jmh530 
    john.michael.hall at gmail.com
       
    Wed Sep 27 20:04:42 UTC 2017
    
    
  
On Wednesday, 27 September 2017 at 19:47:32 UTC, Jean-Louis Leroy 
wrote:
>
> I'd like to go further: find the template arguments and the 
> function arguments and return types. Looking at __traits and 
> std.traits, it doesn't seem feasible, but maybe I overlooked 
> something?
You can use TemplateArgsOf
https://dlang.org/phobos/std_traits.html#TemplateArgsOf
to get the template arguments.
For the stuff below, I think you can't just use foo, it has to be 
a specific foo!T.
You can test if it's a function
https://dlang.org/phobos/std_traits.html#isFunction
You can get the Parameter and Return types
https://dlang.org/phobos/std_traits.html#Parameters
https://dlang.org/phobos/std_traits.html#ReturnType
You can get the names of parameters
https://dlang.org/phobos/std_traits.html#ParameterIdentifierTuple
    
    
More information about the Digitalmars-d
mailing list