C++ Logo

std-proposals

Advanced search

[std-proposals] Class-level opt-in noexcept attribute (non-inheriting)

From: <geguji60_at_[hidden]>
Date: Tue, 4 Aug 2026 20:10:34 +0800 (GMT+08:00)
Hello all,


I’d like to propose a small, local extension to the core language:


a class-head noexcept-specifier, analogous to final or explicit .




Motivation


 noexcept is currently a per-function property. For many types—especially


value types, RAII guards, and low-level utility classes—every member function


can and should be noexcept . Today this must be repeated manually, which is


verbose, error-prone, and easily forgotten during refactoring.


A class-level specifier would make the intent clear and machine-checkable.






Semantics (intended)


The noexcept specifier applies only to member functions declared within the class-body.


It is non-inheriting and non-deductive.


An explicit noexcept on a member declaration overrides the class-level specifier.


Defaulted special members respect the class-level specifier.


The meaning is exactly as if noexcept(true) / noexcept(false) were written on each affected declaration.


The specifier does not affect:


base classes,


derived classes,


out-of-line definitions,


non-member functions,


friends.




​Relationship to existing features



Not noexcept(auto) (N4473): no deduction from function bodies.


Not [[noexcept]] : this is a specifier in the grammar, not an attribute.


Similar to final : applies locally to the class, not inherited, affects declarations within the class body.


Effect on language rules


 noexcept(expr) sees the same result as if the specifier were written manually.


Overload resolution, function pointer type, and mangling are unchanged in semantics—only the source location of the specifier differs.


No ABI impact beyond what manual noexcept already implies.




gauge WG feedback on the general direction.


Thanks,


geguj geguji60_at_[hidden]

Received on 2026-08-04 12:10:44