Passing several tuples (T...) to templates without expanding them

jerro a at a.com
Wed Mar 13 08:49:04 PDT 2013


>>>> and a template
>>>>  template t(alias A, alias B) {
>>>>      // something something
>>>>  }
>>>>
>>>> Given
>>>>  alias Tuple!(int, 1) A;
>>>>  alias Tuple!(int, 1) B;
>>>>
>>>> Is it possible to send this to template t as follows
>>>>  t!(A, B)
>>>> without it expanding to
>>>>  t!(int, 1, int, 1)
>>>> ?

Not as far as I know. You can work that around it by wrapping it 
in a non eponymous template. I use a template like this for this 
purpose:

template group(a...){ alias a members; }

then you do

alias A = group!(int, 1);
alias B = group!(int, 1);

t!(A, B)

And you use A.members and B.members inside t. You could also 
declare A and B as you did above, and use t like this:

t!(group!A, group!B)


More information about the Digitalmars-d-learn mailing list