[phobos] Proposal of StopWatch module

Andrei Alexandrescu andrei at erdani.com
Thu Aug 19 21:03:17 PDT 2010


> Well, if you have unions you could probably do casts in a library. I'm
> not saying we should do this, just that it's possible. For example:
>
> U cast(T)(T ptr) if(isPointer!T && isPointer!U) {
> union U {
> T t;
> U u;
> }
>
> U myUnion;
> myUnion.t = ptr;
> return myUnion.u;
> }

It's a good point, but that's only for certain cases of reinterpret 
cast. Object casts and in particular interface-to-Object and other 
cross-casts won't work that way.

Andrei


More information about the phobos mailing list