www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - typeof from TypeInfo

reply Steve Teale <steve.teale britseyeview.com> writes:
If I have an int say, I can declare another of the same

int a;
typeof(a) b;

If I have a TypeInfo instance ti, it would be nice to be able to do 
something similar, either special-case it, or have a property or method 
on Typeinfo.

typeof(ti) x;
ti.typeof y;

It's probably already there and I just haven't found it/worked it out yet.

Something of this sort would make the code in typesafe varadic functions 
much more succinct

_arguments[i].typeof a = va_arg!(arguments[i].typeof)(args);

Steve
Mar 20 2010
parent Daniel Keep <daniel.keep.lists gmail.com> writes:
Steve Teale wrote:
 If I have an int say, I can declare another of the same
 
 int a;
 typeof(a) b;
 
 If I have a TypeInfo instance ti, it would be nice to be able to do 
 something similar, either special-case it, or have a property or method 
 on Typeinfo.
 
 typeof(ti) x;
 ti.typeof y;
 
 It's probably already there and I just haven't found it/worked it out yet.
 
 Something of this sort would make the code in typesafe varadic functions 
 much more succinct
 
 _arguments[i].typeof a = va_arg!(arguments[i].typeof)(args);
 
 Steve
TypeInfo is a run-time value. typeof is a Type expression which makes it a compile-time construct. You cannot go run-time -> compile-time.
Mar 20 2010