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

--- Comment #5 from Daniel Trebbien <dtrebbien at gmail dot com> ---
I have run into a small issue. C++11 apparently does not provide an exception
guarantee on vector::resize(size_type), whereas in C++14, the exception
guarantee is "If an exception is thrown other than by the move constructor of a
non-CopyInsertable T there are no effects."

Given that C++11 does not provide a guarantee, I was thinking that it would be
fine to implement C++14's guarantee when compiling as C++11. However, there are
several questions that I have seen on Stack Overflow alone which mention or
imply that vector::resize falls back on copying existing elements if the _Tp
move constructor is not noexcept:
https://stackoverflow.com/questions/6011428/move-constructors-and-the-strong-exception-guarantee
https://stackoverflow.com/questions/21592898/c-11-move-semantics-and-stl-containers/
https://stackoverflow.com/questions/28627348/noexcept-and-copy-move-constructors/
https://stackoverflow.com/questions/47604029/move-constructors-of-stl-containers-in-msvc-2017-are-not-marked-as-noexcept/

So, my question is, if __cplusplus is 201103L (C++11 mode), should the call to
std::__uninitialized_move_if_noexcept_a be retained, thus providing a strong
exception guarantee along the lines of "If an exception is thrown there are no
effects.", and preserving backward-compatibility. Or, is it okay to implement
C++14's exception guarantee, which is not as strong, in C++11 mode as well?

Reply via email to