0 or 0L for empty pointers?

Guillaume Laurent glaurent at telegraph-road.org
Fri Jun 23 16:46:42 BST 2006


Allan Sandfeld Jensen wrote:
> On Friday 23 June 2006 14:03, Stefan Teleman wrote:
>   
>> 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.
>>
>>     
> It is _not_ your friend, since you can't trust it.
Come on. You can trust it except in some very specific cases. We've been 
happily using it all over our code in Rosegarden without a problem.

> Even with ways to make it work. It's kinda cryptic
"kinda cryptic" ?? What's cryptic about it ?

> (personally I prefer C-casts, but I guess I'm just 
> oldfashioned). 
>   
Let me get this straight : you think dynamic_cast<> is unreliable and 
prefer C style casts instead ? This begs for the usual question : 
"what's the color of the sky on your planet ?".

> Also while it doesn't cost you very much to use dynamic_cast<>; if you don't 
> use it at all, you can disable C++ RTTI and save a lot of memory and speed.
>   
Oh, because whatever home-made mechanism you'll devise to replace it 
will be cost-free ?

-- 
Guillaume
http://telegraph-road.org





More information about the kde-core-devel mailing list