Getting the typeid of an object disguised under an interface
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Mon Mar 28 07:31:57 PDT 2016
On Monday, 28 March 2016 at 11:58:17 UTC, Tomer Filiba wrote:
> Object interfaceToObject(I)(I obj) if (is(I == interface)) {
> import object;
> return cast(Object)(cast(void*)obj -
> ((cast(Interface*)obj.__vptr[0]).offset));
> }
eeek, plain `cast(Object) obj` works for this! You don't need all
that other stuff.
> It would be really nice if TraceInfo exposed the callstack to
> the user. It only provides an opApply that converts to it
> string... adding a simple property such as
You could always call the backtrace function from the debug info
if you are on Linux.
http://man7.org/linux/man-pages/man3/backtrace.3.html
That's what trace info used to do. (now it does it itself but
same thing)
More information about the Digitalmars-d
mailing list