typeid reversing ?
Daniel919
Daniel919 at web.de
Sun Sep 3 10:34:48 PDT 2006
Hi,
just had some thoughts about casting and types.
--------------------------------
import std.string;
import std.stdio;
void giveparam(int a) {
writefln("takeparam " ~ format(a));
}
void variadic( ... ) {
if(_arguments[0] == typeid(int))
giveparam(* cast(int *) _argptr);
//else if(_arguments[0] == typeid(double))
//... and so on
}
/*
given......................: _arguments[0] == typeid(int)
if this would be possible..: ???(_arguments[0]) == int;
I could write giveparam like this:
giveparam(* cast(???(_arguments[0]) *) _argptr);
and would not be forced to do if-checking for all types
*/
void main() {
variadic(1);
}
---------------------------------------
Is there a way to do this ? If not, could something like this be integrated
to D ?
Thanks for your replies in advance.
Daniel
More information about the Digitalmars-d-announce
mailing list