0 or 0L for empty pointers?
Stefan Teleman
steleman at nyc.rr.com
Fri Jun 23 13:03:48 BST 2006
On Friday 23 June 2006 07:42, Frans Englich wrote:
> Yes, some features should be avoided
> in any case like dynamic_cast, but perhaps there's some template
> features or the like that should be avoided.
Just out of curiosity, why is dynamic_cast<> a Bad Thing(TM) ?
I think dynamic_cast<> is your friend. It comes with failure guarantee
which returns NULL for pointers (a Good Thing(TM)). It throws for
references but then i've rarely seen it used on references anyway.
The legend that dynamic_cast<> is slow is really an Urban Myth these
days. For any half-decent compiler dynamic_cast<> is nothing more
than a simple pointer arithmetic in the __vtbl, unless the class
inheritance tree is a really weird-shaped directed acyclic graph with
several branches and the C++ run-time has to go through several
__vtbl jumps to resolve to the proper type.
--Stefan
--
Stefan Teleman 'Nobody Expects the Spanish Inquisition'
steleman at nyc.rr.com -Monty Python
More information about the kde-core-devel
mailing list