Passing several tuples (T...) to templates without expanding them
simendsjo
simendsjo at gmail.com
Wed Mar 13 04:26:23 PDT 2013
On Wednesday, 13 March 2013 at 11:21:53 UTC, simendsjo wrote:
> On Wednesday, 13 March 2013 at 11:13:55 UTC, monarch_dodra
> wrote:
>> On Wednesday, 13 March 2013 at 10:34:14 UTC, simendsjo wrote:
>>> Say you have a tuple type:
>>> struct Tuple(T...) {
>>> alias T Tuple;
>>> }
>>>
>>> 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)
>>> ?
>>>
>>> This is what I'm trying to achieve, but encapsulated in a
>>> template:
>>> alias Tuple!(int, "aoeu", short) A;
>>> alias Tuple!(int, "aoeu", short) B;
>>> foreach(i, T; A) {
>>> pragma(msg, i, " ", T);
>>> pragma(msg, isEqual!(T, B[i]));
>>> }
>>
>> I have trouble understanding the question. Perhaps you are
>> confusing Tuple and TypeTuple?
>
> I'm not using phobos Tuple as it didn't work well with both
> types and values.
> I want a Tuple!(int, 1, "aoeu") to have exactly these values;
> int, 1, "aoeu".
>
> alias Tuple!(int, 1) T; // Attempted to instantiate Tuple
> with an invalid argument: 1
Ahem.. Seems TypeTuple is exactly like my Tuple, so I'll change
my code to use TypeTuple. The question still stands though..
If it's not possible, as you say, I'll try to figure out a
workaround..
More information about the Digitalmars-d-learn
mailing list