Dynamic and Static Casting

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 10 05:33:48 PST 2011


On Thu, 10 Feb 2011 08:02:08 -0500, d coder <dlang.coder at gmail.com> wrote:

> Thanks Lars and Bearophile, I will give it a try.
>
> I understand that static downcasting is dangerous. But there are
> places where efficiency is paramount and you are sure that the casting
> is safe. So I wholeheartedly second your proposal to have the stuff in
> phobos.

Be aware that blindly casting interfaces is not a good idea.  An interface  
pointer is offset into the object and the cast *must* be dynamic.

Casting objects from one class to another should be reliable, however.

-Steve


More information about the Digitalmars-d-learn mailing list