Boost logo

Boost :

Subject: Re: [boost] Old style casts and Boost style guidelines
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-09-15 20:52:28

Edward Diener:
> Peter Dimov wrote:
>> (Y*)0 is so much nicer than static_cast< Y* >( 0 )... :-/
> It is shorter, as are most uses of old-style casts as opposed to C++
> new-style casts, but what makes it "nicer" ?

It's easier to read. C-style casts, in general, are shorter, but not
necessarily easier to read, because one needs to look up the source (and
sometimes target) types to determine what the cast actually does (is it a
static_cast, a reinterpret_cast, a const_cast, or a combination) and whether
it's correct. This slows the reader down, which is not nice.

In this case, though, the meaning is unambiguous. (Y*)0 is - obviously - a
null pointer "literal" of type Y*. So it's nice. :-)

Boost list run by bdawes at, gregod at, cpdaniel at, john at