Extracting Params of Templated Type
Meta
jared771 at gmail.com
Thu Apr 3 22:02:27 PDT 2014
On Friday, 4 April 2014 at 04:44:56 UTC, Nick Sabalausky wrote:
> If you have a templated type, is there a way to get the
> compile-time parameters it was instantiated with?
>
> Ie:
>
> ----------------------
> struct Foo(T) {}
>
> alias MyFoo = Foo!int;
> ----------------------
>
> Is there a way to inspect MyFoo to get its T type (in this
> case, 'int')? *Without* actually making any changes to Foo to
> explicitly support this?
alias TemplateArgs(T: Foo!U, U) = U;
void main()
{
assert(is(TemplateArgs!MyFoo == int));
}
More information about the Digitalmars-d-learn
mailing list