This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug libstdc++/80579] std::vector<T>::reserve should not require T to be moveable.


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80579

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ville.voutilainen at gmail dot com
          Component|c++                         |libstdc++

--- Comment #1 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Well, clang 5.0 on wandbox rejects the code:
https://wandbox.org/permlink/W6hDjCOfqNRecpnU

vector::reserve requires MoveInsertable(*), B isn't MoveInsertable.
This is not an implementation bug, libstdc++ conforms to what the
standard specifies.

(*) ..because reserve might reallocate, so if it does, the elements
need to be moved to a new buffer. An implementation is not required
to copy the elements if moving them isn't valid, quite the opposite;
an implementation is allowed to assume that it can move. We could
be really nice and do that as a response to the violation of the
MoveInsertable precondition.

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