safer casts - take II

BCS ao at pathlink.com
Tue May 13 11:47:26 PDT 2008


Reply to terranium,


> 1) if(auto x=cast(X)y) will probably throw in a predicted location,
> workaround - when porting, replace cast with dynamic_cast template
> (which should be provided by standard library for porting legacy code)

The proposed dynamic_cast template, can't be implemented safely and efficiently 
with the primitives you propose.*

The primitives you propose can be safely and efficiently implemented with 
the ones Yigal proposed.

*You either get a redundant downcast check, invoke the exception handling 
system or you need to use reinterpret_cast.





More information about the Digitalmars-d mailing list