The Lakos rule is important as a means to allow what would
otherwise be undefined behavior to (in some cases) produce a
thrown exception. This allows, for example, a function to throw an
exception upon detection of a precondition violation. This can be
desirable as a bug detection mechanism in debug builds but where
such detection is not desirable for production builds due to
overhead. See also Ville's response regarding contracts.
You might also be interested in P2946 (A Flexible Solution to the
Problems of noexcept).
Tom.
I see people arguing that the Lakos rule should be kept, and others saying it should be abolished.
For everyone to meet half way, what if the Standard library could do:
namespace std {int SomeFunc(int,int) noexcept_Lakos;}
A function marked as 'noexcept_Lakos' is said to be a 'Lakos function'.
So then if you want a Lakos function to be 'noexcept', you do something like:
void MyFunc(int const a, int const b) noexcept{using noexcept_Lakos;// The above line ensures that all// Lakos functions called in this// function won't throwreturn 2 * std::SomeFunc(a,b);}
Or if you just want to single-out one function call:
void MyFunc(int const a, int const b) noexcept{return 2 * _Lakos(std::SomeFunc(a,b));}