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.
E.g. precondition specifies the checkable precondition.
Hardened mode: Tested at runtime, throws exception or terminates program (selectable).
Unhardened mode: No test at runtime / UB.
Some facility to check a precondition separately from the function call.
-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Do 17.09.2026 14:29
Betreff: Re: [std-proposals] noexcept(static)
An: std-proposals@lists.isocpp.org;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;
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@lists.isocpp.org https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals