
1 Oct
2009
1 Oct
'09
1:21 a.m.
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