[Issue 3272] New: RepresentationTypeTuple! in std.traits does not work for classes.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 29 13:42:05 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3272

           Summary: RepresentationTypeTuple! in std.traits does not work
                    for classes.
           Product: D
           Version: 2.029
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: peng2cheng2 at yahoo.com


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);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list