Stop TypeTuple as template parameter from expanding

Tobias Pankrath tobias at pankrath.net
Fri Nov 4 03:02:43 PDT 2011


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

-- 
Tobias


More information about the Digitalmars-d-learn mailing list