Bug 3272 – RepresentationTypeTuple! in std.traits does not work for classes.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-08-29T13:42:00Z
Last change time
2015-06-09T01:26:25Z
Keywords
rejects-valid
Assigned to
andrei
Creator
peng2cheng2

Comments

Comment #0 by peng2cheng2 — 2009-08-29T13:42:04Z
RepresentationTypeTuple! in std.traits does not work for classes. It does work for structs. Just not implemented yet? import std.traits; import std.stdio; struct S { int a; string s; } class C { //public: int a = 2; string s = "xx"; } void main (char[][] args) { //works for struct alias RepresentationTypeTuple!(S) SR; pragma(msg, "S's field types: " ~ SR[0].stringof ~ ", " ~ SR[1].stringof); //same thing for class causes index out of bounds error alias RepresentationTypeTuple!(C) CR; // pragma(msg, "C's field types: " ~ CR[0].stringof ~ ", " ~ CR[1].stringof); pragma(msg, "C's field types? " ~ CR[0].stringof); C c = new C; writeln(c.a, " ", c.s); }
Comment #1 by andrei — 2011-01-23T20:14:35Z