degski wrote:
On Sun, 3 Mar 2019 at 14:39, Peter Dimov via Boost
wrote: The behavior of emplace varies depending on a number of things:
- whether all types are trivially destructible - whether the variant is single- or double-buffered - whether the type we're constructing is nothrow constructible from the arguments - whether all contained types are trivially move constructible and move assignable - and finally, whether, in the single buffered case, we have a monostate type
Do I need to remember all of the above to correctly use variant2 (and not run into trouble)?
No. The high-level behavior is the same - emplace<i>(args...) replaces the currently held value with Ti(args...), and on exception, the variant holds "a valid but unspecified value".