Function traits at compile time
Victor Nakoryakov
nail-mail at mail.ru
Mon Jun 12 11:54:07 PDT 2006
Daniel Keep wrote:
> Victor Nakoryakov wrote:
>
>>Hi all,
>
>
> Hi.
>
>
>>Consider code:
>>
>>class MyClass(StructT)
>>{
>>....
>>}
>>
>>I know, that StructT has a function `foo` in it, but I don't know number
>>of parameters and their types, of course. Does anybody knows a way to
>>extract types to use them in `static if ( is(...) )` statements?
>
>
> Ok, this is ugly, and evil, evil hack, but it works. The python script
> that generated it is included if you need more and/or less arguments.
>
> Some examples:
>
> # NumberOfArgs!(&StructT.foo); // Number of arguments
> # ReturnType!(&StructT.foo); // Alias to return type
> # ArgType!(&Struct.foo, n); // Alias to type of 'n'th argument
> # // (counting from 1).
>
> Hope this helps :)
>
> -- Daniel
>
Thank you, I'll take a look.
--
Victor (aka nail) Nakoryakov
nail-mail [at] mail.ru
Krasnoznamensk, Moscow, Russia
More information about the Digitalmars-d
mailing list