Need help understanding Tuple

d coder dlang.coder at gmail.com
Tue Dec 18 03:05:20 PST 2012


Greetings

Somebody please help me understand why we need the Tuple template in the
following code. Does not __traits(getAttributes, foo.a) return a tuple? So
what is the Tuple template doing here? Converting a tuple to a tuple?

Also where to learn more about tuples in D. Info in TDPL is sketchy.

Regards
- Puneet

template Tuple(T...) {
  alias T Tuple;
}

enum Bar;
class Foo {
  @Bar int a;
}

void main()
{
  Foo foo = new Foo;
  alias Tuple!(__traits(getAttributes, foo.a)) tp;
  pragma(msg, tp);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20121218/f9455dc8/attachment.html>


More information about the Digitalmars-d-learn mailing list