[libcxx-commits] [PATCH] D62228: Make `vector` unconditionally move elements when exceptions are disabled.

Eric Fiselier via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 21 19:08:29 PDT 2019


EricWF created this revision.
EricWF added reviewers: mclow.lists, ldionne, rsmith.
EricWF added a project: libc++.
Herald added subscribers: dexonsmith, christof.

`std::vector<T>` is free choose between using copy or move operations when it needs to resize. The standard only candidates that the correct exception safety guarantees are provided. When exceptions are disabled these guarantees are trivially satisfied. Meaning vector is free to optimize it's implementation by moving instead of copying.

This patch makes `std::vector` unconditionally move elements when exceptions are disabled.

This optimization is conforming according to the current standard wording.

There are concerns that moving in `-fno-noexceptions`mode will be a surprise to users. For example, a user may be surprised to find their code is slower with exceptions enabled than it is disabled. I'm sympathetic to this surprised, but I don't think it should block this optimization.


Repository:
  rCXX libc++

https://reviews.llvm.org/D62228

Files:
  include/memory
  include/utility
  test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.sh.cpp
  test/libcxx/utilities/utility/forward/extended_move_if_noexcept.sh.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62228.200625.patch
Type: text/x-patch
Size: 8050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190522/70f85a89/attachment.bin>


More information about the libcxx-commits mailing list