C++ Logo

std-proposals

Advanced search

Re: [std-proposals] noexcept(static)

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Thu, 17 Sep 2026 15:07:31 +0200
Yes, Frederick suggested > add a new operator called 'contract_check' instead of writing a separate function, that "operator" could test the precondition clause of the function.   So instead of reinventing the wheel, find out, how the existing wheel serves the exact purpose, or whether it would be enough to add small facilities or tweaks.   -----Ursprüngliche Nachricht----- Von:Jonathan Grant via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Do 17.09.2026 15:08 Betreff:Re: [std-proposals] noexcept(static) An:std-proposals_at_[hidden]; CC:Jonathan Grant <jgrantonline_at_[hidden]>; 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 >       > > -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-09-17 13:14:22