C++ Logo

std-proposals

Advanced search

Re: [std-proposals] auto-noexcept for move and lambdas

From: Andre Kostur <andre_at_[hidden]>
Date: Mon, 9 Jun 2025 08:20:00 -0700
Food for thought: there may be a silent performance degradation if
such a constructor were to "accidentally" get a noexcept(false)
function call somewhere. Or some member variable (or
member-of-a-member, etc) loses its noexcept(true) status.

On Mon, Jun 9, 2025 at 7:33 AM Nikl Kelbon via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> It would be nice to add automatic noexpect detection, if it is not explicitly set, for the move constructor, move assign operator and for lambdas
> Use cases: move constructor not marked as noexcept is performance bug
>
> Typical scope exit implementations checks noexcept function or not in destructor, it may force them to make useless actions or make scope_exit not std::destructible (throw constructor)
>
> How ?
>
> Just check every expression in lambda / move constructor / move assign if it may throw by current C++ rules and noexcept == 9noexcpt(exprs) || ...)
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-06-09 15:20:13