How to convert int type to string "int" ?

bioinfornatics via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 1 06:34:20 PDT 2014


Hi,

All is in the title.
I need this to do a tupleof enhanced, that mean:
    - .tupleof need an instance me i want to do this on type
diretcly
    - .tupleof do not bind to member name i need this


for this i strat to this code:

import std.stdio;
import std.typecons;
import std.conv;

struct Coord
{
      int x;
      int y;
      int z;
}

template toTuple(T){
      static string maker(){
          string statement = "alias Tuple!(";
          foreach(const memberName; __traits(allMembers, T)){
              statement ~=  to!string(typeof(__traits(getMember, T,
memberName)))  ~ ",\"" ~ memberName ~ "\", " ;
          }
          statement = statement[O..$-1] ~ ") t;" ; // $-1 to remove
extra comma
          return statement;
      }
      enum toTuple = mixin( maker() );
}


but that fail on typeof(__traits(getMember, T, memberName) becase
that return a type and not a string.


Thaks for your help


More information about the Digitalmars-d-learn mailing list