Boost logo

Boost :

Subject: Re: [boost] [variant] Basic rvalue and C++11 features support
From: Peter Dimov (lists_at_[hidden])
Date: 2013-01-11 09:18:20

Larry Evans wrote:
> I further jumped to the conclusion that *if* the variant had a
> null state, then it would not assume any of its bounded types
> were "in effect"; hence, would not call any destructors
> for any bounded type or perform any operations on any bounded
> type; hence, the pointer in recursive wrapper would not even
> need to be zeroed because the containing variant would not
> assume that it even had a recursive_wrapper as one of its
> bounded types.

You're quite correct. The problem does not stem from inadequate tagging
though. The problem stems from the never-empty guarantee:

If the variant could be empty, or equivalently, if the variant always
contained a type that can be reliably default-constructed (without an
exception) such as int, the problems with assignment (both copy- and move-)
and with move construction do not occur, because the target can be left
holding the int.

So, one option is to enable move only in this case.

Boost list run by bdawes at, gregod at, cpdaniel at, john at