C++ Logo

std-discussion

Advanced search

Re: noexcept(auto)?

From: Yongwei Wu <wuyongwei_at_[hidden]>
Date: Tue, 16 Apr 2024 10:50:08 +0800
An immediate objection I can think of myself: Changing the
implementation may change the noexcept specification, so it is
probably not a good idea that this can become the default. Still, it
may be quite useful in function templates, where currently we
sometimes use complicated noexcept conditions to determine the
noexcept specification...

On Tue, 16 Apr 2024 at 10:43, Yongwei Wu <wuyongwei_at_[hidden]> wrote:
>
> I am not sure whether it is a good idea or not, or whether someone
> proposed it before, but it suddenly occurred to me maybe we can use
> noexcept(auto) to make the compiler analyse the function body, and
> mark the function as noexcept(true) if there is nothing in the
> function body that causes an exception, and as noexcept(false) if
> there is a throw statement in the function body or if an non-noexcept
> function is invoked.
>
> Of course the limitation is that the function body must be available
> when using the noexcept(auto) mark. With modules introduced, this
> seems an even lesser concern now. Using it in a prototype declaration
> is ill-formed. If the declared function prototype and the later
> function definition result in different noexcept specifications, the
> program is ill-formed too.
>
> If this is feasible, maybe one day we can make noexcept(auto) the
> default when the function body is provided?
>
> --
> Yongwei Wu
> URL: http://wyw.dcweb.cn/



-- 
Yongwei Wu
URL: http://wyw.dcweb.cn/

Received on 2024-04-16 02:50:21