Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.any] Inline allocation of small objects in any.
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-02-09 11:14:38


At Wed, 09 Feb 2011 06:44:42 -0800,
Steven Watanabe wrote:
>
> AMDG
>
> On 2/8/2011 11:54 PM, Adarsh Soodan wrote:
> > On Wed, Feb 9, 2011 at 1:07 PM, Nevin Liber<nevin_at_[hidden]> wrote:
> >
> >> What are your exception safety guarantees compared with the current
> >> implementation of boost::any?
> >>
> >
> > I do not see the exception safety gurantees required of the held value
> > object changing from the original any.hpp.
> >
>
> What about swap? swap is no-throw now.

Just to be a little less opaque about this, everyone is asking because what you
did is very similar to what's done in boost::variant, which led to some very
interesting problems described in
http://www.boost.org/doc/libs/1_45_0/doc/html/variant/design.html#variant.design.never-empty
with very non-obvious solutions.

So you might also consider what happens under assignment when the constructor of
the new object throws.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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