Subject: Re: [boost] [variant] Basic rvalue and C++11 features support
From: Peter Dimov (lists_at_[hidden])
Date: 2013-01-11 11:35:50
Paul Smith wrote:
> It is a heuristic. Just because something is no-throw doesn't
> necessarily mean that it's cheap.
Well, if the variant picks the first such type, the user can place his
preference first in the list.
> Still, there's no need to supress move construction in the absence of
> a no-throw default constructible type.
No, you could still keep the current behavior.
Incidentally, now that I think of it, the first implementation strategy in
is possible when the target type has a nothrow move constructor. You could
move-construct the temporary backup, destroy the target and if the copy
fails, move-construct it back. So the assignment would go along the
- if the types are the same, assign
- if the source type has a nothrow copy* constructor, use it
- if the target type has a nothrow move constructor, use it
- if there is a nothrow-default-constructible type, use it
- otherwise, do the heap backup thing
* For move assignment, change copy* to move
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk