C++ Logo

std-proposals

Advanced search

Re: [std-proposals] noexcept(static)

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 04 Sep 2026 18:13:34 -0300
On Friday, 4 September 2026 12:25:08 Brasilia Standard Time Bingzhi via Std-
Proposals wrote:
> Nice feature!
> I have some questions:
> Should it be SFINAE-friendly?
> Should it matter in function template overloading?

No.

The behaviour from the caller's perspective is exactly identical: such a
function will never throw. How it guaranteed such feat is not important to the
caller, therefore should not be part of the function's signature.

Moreover, that means the definition / implementation of the function should be
able to declare it wants the checking, independent of how the function was
previously declared in a header.

> I'd like to write:
> namespace optimized_versions
> {
>
> template <class Book> void reorder(Book& b) noexcept(static) { ... } //
> optimized noexcept version template <class Book> void reorder(Book& b)
> noexcept(false) { try { ... } catch (...) { ... } }>
> }
> instead of writing ``requires requires { { ... } noexcept; }`` constraints
> for that noexcept version.

Right, that's for noexcept(true) vs noexcept(false). That's an independent
problem and feature request to this thread.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-09-04 21:13:46