Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-02-21 13:50:32

"Peter Dimov" <pdimov_at_[hidden]> wrote in message
> Fernando Cacciola (Home) wrote:
> [...]
> > One is initialization from a null pointer value, as in:
> >
> > struct C
> > {
> > C() : ptr(0) {}
> >
> > shared_ptr<X> ptr ;
> > } ;
> >
> > this one is very useful because its very idiomatic.
> Use
> C() : ptr() {}
> instead; it is supposed to work for any pointer.
I know I can do this instead.
But my point is that we rarely do it :-)
Value-initialization is not as idiomatic as it should, specially if you
consider the highly generic case of a 'general' pointer (either built-in or
Neither is (!p) and (!!p) or (p) instead of (p==0) and (p!=0),

Just take a look at almost any boost code (shared_ptr.hpp, for example); the
null pointer value is used a lot (not only in initialization but in testing

So, having support for null-pointer-value in a smart ptr makes it more
'pointer-like' in light on the de-facto idioms still in broad usage today.

Anyway, I agree with Daniel Frey in that putting this into shared_ptr will
disallow stricter guidelines.

Fernando Cacciola

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