D is awesome, my situation, questions
mike.benfield at gmail.com
mike.benfield at gmail.com
Sun Jun 4 02:56:18 PDT 2006
In article <e5u46f$hbe$1 at digitaldaemon.com>, Johan Granberg says...
>
>I to would like tuples (and the other things to) but I realy thing
>tuples should bee an Built in type.
>
>Syntax proposal: tuple(type,type,type)
Why would you prefer tuples to be built in?
I wrote struct templates like this:
struct Tuple(T1, T2) {
T1 _1;
T2 _2;
};
and function templates like this:
template tuple(T1, T2) {
Tuple!(T1, T2) tuple(T1 t1, T2 t2) {
Tuple!(T1, T2) tu;
tu._1 = t1;
tu._2 = t2;
return tu;
}
}
I made templates like this for between 2 and 10 elements.
And you get the same effect. Refer to a tuple type by
Tuple(Type1, Type2) and create one by calling
tuple(value1, value2).
More information about the Digitalmars-d
mailing list