C++ Logo

std-proposals

Advanced search

Re: [std-proposals] noexcept(static)

From: Jonathan Grant <jgrantonline_at_[hidden]>
Date: Thu, 17 Sep 2026 14:08:09 +0100
On 17/09/2026 13:27, Sebastian Wittmeier via Std-Proposals wrote:
> For a certain class of conditions this is done by the contracts pre() precondition specifier.
>
>
>
> Better improve the contracts checking modes to do, what is needed, than invent another way to specify a precondition IMHO.
>

It's very true complexity increases with more keywords, attributes, statements
>
> E.g. precondition specifies the checkable precondition.
>
> Hardened mode: Tested at runtime, throws exception or terminates program (selectable).

Hardened at compile-time would be fantastic, the enforce=static mode.

https://isocpp.org/files/papers/P4363R0.pdf

>
> Unhardened mode: No test at runtime / UB.
>
>
>
> Some facility to check a precondition separately from the function call.

May I clarify, do you mean calling myclass::method::pre() from another method in the same class?

Best regards
Jonathan>
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
> *Gesendet:* Do 17.09.2026 14:29
> *Betreff:* Re: [std-proposals] noexcept(static)
> *An:* std-proposals_at_[hidden];
> *CC:* Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>;
>
>
> On Thursday, September 17, 2026, Sebastian Wittmeier wrote:
>
> Then write a wrapper that is noexcept. Then the program terminates in those cases or just declare the caller as noexcept.
>
>
>
> Or maybe add a new operator called 'contract_check' which you use like this:
>
> bool is_okay = contract_check( v[i] );
>
> This operator returns a bool to say whether its argument satisfies all contractual requirements. Then you'd add a method to your class:
>
> [[contract_check]] bool vector::operator[](size_t const n)
> {
> return n < this->size();
> }
>
>
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
>
>

Received on 2026-09-17 13:08:15