digitalmars.D.learn - Is there a way to get the types of all template parameters?
- Atila Neves (6/6) Jun 04 2015 For regular runtime parameters, there's ParameterTypeTuple. How
- Meta (4/12) Jun 04 2015 There is http://dlang.org/phobos/std_traits.html#TemplateArgsOf,
- Atila Neves (3/20) Jun 04 2015 Don't know how I missed that, thanks!
- ketmar (4/12) Jun 04 2015 actually, you can't. uninstantiated template cannot be processed by=20
- Atila Neves (5/21) Jun 04 2015 The way I wrote it, no. But if they all have default values, then
- Jacob Carlborg (5/10) Jun 04 2015 Unfortunately this is not implemented yet. But there's a pull request [1...
For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo, Bar) I've tried but my is expression kung fu was weak. Atila
Jun 04 2015
On Thursday, 4 June 2015 at 13:38:20 UTC, Atila Neves wrote:For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo, Bar) I've tried but my is expression kung fu was weak. AtilaThere is http://dlang.org/phobos/std_traits.html#TemplateArgsOf, but it only works with an instantiated template.
Jun 04 2015
On Thursday, 4 June 2015 at 13:50:02 UTC, Meta wrote:On Thursday, 4 June 2015 at 13:38:20 UTC, Atila Neves wrote:Don't know how I missed that, thanks! AtilaFor regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo, Bar) I've tried but my is expression kung fu was weak. AtilaThere is http://dlang.org/phobos/std_traits.html#TemplateArgsOf, but it only works with an instantiated template.
Jun 04 2015
On Thu, 04 Jun 2015 13:38:18 +0000, Atila Neves wrote:For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. =20 void fun(Foo foo, Bar bar)() {} =20 alias types =3D CtParameterTypeTuple!fun; //TypeTuple!(Foo, Bar) =20 I've tried but my is expression kung fu was weak.actually, you can't. uninstantiated template cannot be processed by=20 anything, as it's not semanticed yet. and to semantic it, you have to=20 instantiate it.=
Jun 04 2015
On Thursday, 4 June 2015 at 14:12:08 UTC, ketmar wrote:On Thu, 04 Jun 2015 13:38:18 +0000, Atila Neves wrote:The way I wrote it, no. But if they all have default values, then yes: TemplateArgsOf!(fun!()) AtilaFor regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo, Bar) I've tried but my is expression kung fu was weak.actually, you can't. uninstantiated template cannot be processed by anything, as it's not semanticed yet. and to semantic it, you have to instantiate it.
Jun 04 2015
On 2015-06-04 15:38, Atila Neves wrote:For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo, Bar) I've tried but my is expression kung fu was weak.Unfortunately this is not implemented yet. But there's a pull request [1]. [1] https://github.com/D-Programming-Language/dmd/pull/3515 -- /Jacob Carlborg
Jun 04 2015