Boost logo

Boost :

Subject: Re: [boost] [optional] Doc Nit
From: Fernando Cacciola (fernando.cacciola_at_[hidden])
Date: 2012-11-01 14:35:37


On 26-Oct-12 8:00 PM, Dave Abrahams wrote:
>
>> A typical approach is to consider the existence of a
>> valid return value as a postcondition, so that if the
>> function cannot compute the value to return, it has
>> either undefined behavior (and can use assert in a
>> debug build) or uses a runtime check and throws an
>> exception if the postcondition is violated. This is a
>> reasonable choice for example, for function (A),
>
> This is possibly technically correct, but confusing. Undefined behavior
> results from precondition violations, not postcondition violations.
>
> I'd suggest:
>
> One approach is to make a non-negative argument a precondition, so when
> violated the function has undefined behavior (and can use assert in a
> debug build). Alternatively, one can use a runtime check and specify
> that an exception is thrown if the postcondition cannot be
> satisfied. These are a reasonable choice for example, for function (A),
>
> I'm not sure the first sentence is quite right for your needs, but I'm
> out of time to improve it further.
>
OK, I actually like your suggestion.

I'll change the docs when I'm finished updating the code to use C++11

Best


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk