Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::none for boost::shared_ptr
From: Ben Pope (benpope81_at_[hidden])
Date: 2014-01-29 21:13:01


On 30/01/14 01:27, Chris Stankevitz wrote:
> Hello,
>
> Does boost::shared_ptr offer a way to create an empty shared pointer
> without a lot of typing? Perhaps something analogous to boost::none.
> I am not using c++11.
>
> Thank you,
>
> Chris
>
> ==
>
> using boost::none;
> using boost::optional;
>
> // declare
> f(optional<CSomeReallyLongClassName> Item);
> g(shared_ptr<CSomeReallyLongClassName> pItem);
>
> // invoke f with empty object
> f(none);
>
> // invoke g with empty object
> g(shared_ptr<CSomeReallyLongClassName>());

g(0);

Ben


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