tupleof feature request
bc
mi_emayl_adrez at hotmail.com
Fri Sep 21 13:01:51 PDT 2007
i was thinking, it would be nice if you could do some of these things:
import std.stdio;
template Tuple(E...)
{
alias E Tuple;
}
alias Tuple!(int, int) TL;
void main()
{
TL tl;
struct S
{
int x;
int y;
}
S s;
s.x = 1;
s.y = 2;
tl = s.tupleof;
/* gives:
C:\Code\D\Test\testtuple.d(21): Error: tl is not an lvalue
C:\Code\D\Test\testtuple.d(21): Error: forward reference to type (int,
int)
C:\Code\D\Test\testtuple.d(21): Error: cannot implicitly convert
expression (tuple((s.X),(s.Y))) of type (int, int) to (int, int)
*/
auto tl2 = s.tupleof;
writefln(tl2);
// this outputs '00'. would be nicer if it did '12'
tl2 = s.tupleof; // doesn't compile
s.tupleof = tl2; // doesn't compile
}
More information about the Digitalmars-d
mailing list