Boost logo

Boost :

Subject: Re: [boost] boost::variant and "Current Approach: Temporary Heap Backup" vs "An Initial Solution: Double Storage"
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-09-30 21:21:50


AMDG

Peter Foelsche wrote:
> This means, my assumptions about exceptions safety of boost::variant
> may be wrong.
> Is this following code & assertion valid?
> I would like if I can assume this.
>
> Thanks
> Peter
>
>
> typedef boost::variant<type1, type2> CVariant;
>
> CVariant s(type1());
> try
> { s = type2();
> } catch (...)
> { assert(s.which() == boost::mpl::index_of<CVariant::types,
> type1>::value);
> }

You cannot make this assumption. Assignment for boost::variant
does not provide the strong guarantee.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk