
"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:4AC3D46B.4020008@providere-consulting.com...
AMDG
Peter Foelsche wrote:
1) boost::variant and "Current Approach: Temporary Heap Backup" vs "An Initial Solution: Double Storage" Please provide both solutions. A potential heap allocation may prevent certain application areas.
If any of the variant's types have a no-throw default constructor, then no heap backup is used, because variant can construct an object of that type if an exception is thrown. In practice, this means built-in types, or boost::blank.
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); }