Stop TypeTuple as template parameter from expanding
Justin Whear
justin at economicmodeling.com
Fri Nov 4 09:28:57 PDT 2011
I just use a templated struct.
struct GroupedTypes(T...)
{
alias T Types;
}
Then, if you need to something special with groups, you can create an
override:
//overriding previous Test template...
template Test(T: GroupedTypes!(S), S...)
{
}
Tobias Pankrath wrote:
> Hi,
>
> this is an example
> -----------------------------------------
> template Test(S, T...)
> {
> pragma(msg, "S: " ~ S.stringof);
> pragma(msg, "T: " ~ T.stringof);
> }
> alias TypeTuple!(A, B, C) MyList;
> struct A {};
> struct B {};
> struct C {};
>
>
> void main()
> {
> Test!(MyList, A, B, C);
> }
> --------------------------------------------
>
> If I compile this with dmd, it will print:
> --------------------------------------------
> S: A
> T: (B, C, A, B, C)
> test.d(153): Error: Test!(A,B,C,A,B,C) has no effect
> --------------------------------------------
>
> I don't want MyList to expand to the variadic template arguments. Instead
> I want to provide Test with to different typelists. So it should print
>
> --------------------------------------------
> S: (A, B, C)
> T: (A, B, C)
> --------------------------------------------
>
> How would you do this? Do I need an extra template TypeList?
>
> Thank you
>
More information about the Digitalmars-d-learn
mailing list