Boost logo

Boost :

Subject: Re: [boost] [variant] Please vote for behavior (Was: Basic rvalue and C++11 features seupport)
From: Peter Dimov (lists_at_[hidden])
Date: 2013-01-21 12:42:08


Antony Polukhin wrote:
> III: Make recursive_wrapper and variant cooperate, enable move for variant
> in the presence of recursive_wrappers only when there is at least one type
> that is nothrow-default-constructible, regardless of whether it's current.

That's not quite correct. Move for variant would be always enabled, it just
won't result in a NULL reference_wrapper. For example, if a variant<int,
string, reference_wrapper<string2>> contains int(5), it will continue to do
so after move; and if it contains string("..."), it will hold string() after
move. Only if it had a recursive_wrapper( string2("...") ) would it be int()
after move, and if there was no suitable int in the list, it would either
contain recursive_wrapper( string2("...") ), or recursive_wrapper(
string2() ), depending on how the move constructor of recursive_wrapper is
implemented.

In addition, I'd argue that regardless of whether recursive_wrapper is made
to be NULL after move, variant should still try to prevent exposing it to
the user in the situations where there is an "int" in the list.

> - user may be obscured by the fact, that v2 from the example now contains
> int

Users who are obscured by seeing an int() in v2 would be even more obscured
by seeing a crash if v2 had a NULL recursive_wrapper instead.


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