std::vector default default and move constructors

François Dumont frs.dumont@gmail.com
Thu Jan 18 21:01:00 GMT 2018


On 16/01/2018 01:20, Jonathan Wakely wrote:
> On 15/01/18 22:32 +0100, François Dumont wrote:
>> On 15/01/2018 13:29, Jonathan Wakely wrote:
>>> In fact it introduces a serious regression because of this line:
>>>
>>>> -      vector(vector&& __x) noexcept
>>>> -      : _Base(std::move(__x)) { }
>>>> +      vector(vector&&) = default;
>>>
>>> Consider what happens if we have an allocator that is not
>>> nothrow-move-constructible, which can happen if the allocator has a
>>> noexcept(false) move constructor, or more likely just has no move
>>> constructor but has a noexcept(false) copy constructor:
>>>
> One of the move constructors needs to be defined with a function body,
> not defaulted, so that it can also be declared noexcept

Here is an updated patch with this change. Do you also want an explicit 
noexcept on the vector(vector&&) default declaration ? Ok to commit this 
vector patch ?

I was going to propose a similar patch for vector<bool> but checking 
Standard there is not this noexcept qualification on the move constructor.

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: vector.patch
Type: text/x-patch
Size: 12284 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20180118/0d88aef0/attachment.bin>


More information about the Libstdc++ mailing list