Re: Introspect alias name of an aliased type

2016-05-23 Thread Rene Zwanenburg via Digitalmars-d-learn

On Monday, 23 May 2016 at 10:45:49 UTC, ParticlePeter wrote:

Is there a way to get the alias uint32_t instead ?


Nope. For the compiler uint32_t and uint are the same thing, this 
is by design. Typedef can be used to create a separate type with 
the same semantics as the type it's based upon:


https://dlang.org/phobos/std_typecons.html#.Typedef


Introspect alias name of an aliased type

2016-05-23 Thread ParticlePeter via Digitalmars-d-learn

alias uint32_t = uint;

struct Offset() {
  uint32_t x;
  uint32_t y;
}

// Introspect with:

void printStructInfo( T )( T info ) {
  import std.stdio : writefln;
  foreach (memb; __traits(allMembers, T)) {
writefln(typeof(__traits(getMember, info, memb)).stringof);
  }
}

// Result is uint

Is there a way to get the alias uint32_t instead ?