[libcxx-commits] [libcxx] [libc++] Document the strengthened noexcept convention (PR #203869)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 24 05:35:42 PDT 2026
================
@@ -225,3 +225,22 @@ after the function they are measuring, with a few transformations to help filter
When multiple benchmarks measure the same function under different circumstances, we add context as a parenthesis
after the function signature. For example, ``std::vector<bool>::ctor(Self&&, const allocator_type&) (equal allocators)``
would be the allocator-aware move constructor for ``std::vector<bool>`` in the case of equal allocators.
+
+Mark strengthened ``noexcept`` specifiers with ``// strengthened``
+==================================================================
+
+The C++ standard explicitly permits implementations to add ``noexcept`` to non-virtual library
+functions whose specification does not require it (`[res.on.exception.handling]/5
+<http://eel.is/c++draft/res.on.exception.handling#5>`_):
+
+ An implementation may strengthen the exception specification for a non-virtual function by
+ adding a non-throwing exception specification.
+
+Every libc++ ``noexcept`` clause that goes beyond what the standard mandates is annotated with an
+end-of-line ``// strengthened`` comment:
+
+.. code-block:: cpp
+
+ _LIBCPP_HIDE_FROM_ABI constexpr expected() noexcept(is_nothrow_default_constructible_v<_Tp>) // strengthened
----------------
philnik777 wrote:
```suggestion
constexpr expected() noexcept(is_nothrow_default_constructible_v<_Tp>) // strengthened
```
Since it's not really needed for the example nor will we likely required it in most places in the future.
https://github.com/llvm/llvm-project/pull/203869
More information about the libcxx-commits
mailing list