"Peter Dimov" <[EMAIL PROTECTED]> wrote in message
006901c2d9c2$1db8fa60$1d00a8c0@pdimov2">news:006901c2d9c2$1db8fa60$1d00a8c0@pdimov2...
> 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
smart).
Neither is (!p) and (!!p) or (p) instead of (p==0) and (p!=0),
unfortunately.

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
too)

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





_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to