0 or 0L for empty pointers?

Lubos Lunak l.lunak at suse.cz
Fri Jun 23 16:36:19 BST 2006


On Friday 23 June 2006 16:32, 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. See the other replies.
>
> Even with ways to make it work. It's kinda cryptic and just shouldn't be
> trusted. If you need failure safe type-casting, do your own type-system/use

 Yet another own type system? Yes, you are oldfashioned.

> Qt's and use static_cast<> (personally I prefer C-casts, but I guess I'm
> just oldfashioned).
>
> 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.

 The first and second half of this sentence obviously contradict. The one 
that's wrong is the second half.

-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/




More information about the kde-core-devel mailing list