4 ms·
[[noexcept]] was never intended to be a standalone performance boost for arbitrary functions – it was proposed & accepted so container types could make the "str
by favorited 2y ago
[[noexcept]] was never intended to be a standalone performance boost for arbitrary functions – it was proposed & accepted so container types could make the "strong guarantee" (of the so-called Abrahams guarantees): operations can fail, but failed operations have no side-effects.
It allows, for example, std::vector's resize operation to move its contents rather than copying them, iff its element's move constructor is [[noexcept]]. If the move constructor could throw, the items must be copied so the original buffer is unchanged until the entire copy transaction is complete.
std::move_if_noexcept <https://en.cppreference.com/w/cpp/utility/move_if_noexcept https://en.cppreference.com/w/cpp/utility/move_if_noexcept>
"N3050: Allowing Move Constructors to Throw (Rev. 1)" (2010) <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n30...>
"P2861R0: The Lakos Rule – Narrow Contracts and noexcept
Are Inherently Incompatible" (2023) <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2861r0.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p28...>
"P2946R1: A Flexible Solution to the Problems of noexcept" (2024) <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2946r1.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p29...>