This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::vector default default and move constructors

On 18/01/18 22:01 +0100, François Dumont wrote:
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 ?

Yes please.

Ok to commit this vector patch ?

Please wait for Stage 1, it's too late for changes that don't fix any
bugs and risk introducing new ones.

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

We can strengthen noexcept guarantees, but we can't weaken them, so
it's OK to add it to vector<bool> if our implementation cannot throw.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]