Boost logo

Boost Users :

From: Andrew R. Thomas-Cramer (artc_at_[hidden])
Date: 2002-05-13 14:50:49


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
To: <Boost-Users_at_[hidden]>
Sent: Monday, May 13, 2002 1:44 PM
Subject: Re: [Boost-Users] boost::shared_ptr and NULL

> From: "Andrew R. Thomas-Cramer" <artc_at_[hidden]>
> >
> > In this function declaration, is there a simpler way to express a null
> shared pointer as the default argument value?
> > void foo( const boost::shared_ptr<T> & p = boost::shared_ptr<T>( ) );
> >
> > In this function call, is there a simpler way to express a null shared
> pointer as the actual argument?
> > foo( boost::shared_ptr<T>( ) );
>
> No to both. In 1.27 boost::shared_ptr can be constructed from the literal 0,
> but the constructor is explicit. In 1.28, the literal 0 is no longer a valid
> argument to the constructor.

Has there been any discussion in the past about supporting a more
concise/readable value? E.g., the second call below appears more readable to me.
(This particular example relies on "boost::null" being a class with a default
constructor, and boost::shared_ptr providing a non-explicit constructor
accepting a boost::null instance as an argument; this may be flawed.)

    foo( boost::shared_ptr<MyVeryLongClassName>() );
    foo( boost::null() );


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net