Boost logo

Boost :

Subject: Re: [boost] [Contract] noexcept and custom contract violation handlers
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2012-08-30 14:47:32

On Thu, Aug 30, 2012 at 5:36 AM, Andrzej Krzemienski <akrzemi1_at_[hidden]> wrote:
> Hi,
> I have just realized that there is an interesting interaction between
> "noexcept" and Contract Programming framework. Not only Lorenzo's library,
> but even if contracts were a language feature. N3248 ("noexcept prevents
> library validation",
> recommends that functions with any preconditions should not be declared
> noexcept(true) in case someone wants to report precondition failures via
> exceptions. If preconditions become part of declaration syntax, declaring
> both precondition and noexcept(true) could (and should?) be recognized as
> compile-time error.
> But now also invariants and postconditions come into play: if a function
> declares a postcondition, or our class defines an invariant, should we be
> allowed to declare our function noexcept? What if someone wants to report
> an invariant or postcondition failure via special exception? (I do not have
> a good answer for it.)

I see... I think it should be OK however if you don't report contract
failures using exceptions (but you just let the program terminate in
case of a contract failure). Ideally, if you start throwing from the
contracts and you also use noexcept, the lib will give you a
compile-time error. I'll note this issue and I'll explore it fully
when I start supporting C++11.


Boost list run by bdawes at, gregod at, cpdaniel at, john at