Boost logo

Boost :

Subject: Re: [boost] Looking for thoughts on a new smart pointer: shared_ptr_nonnull
From: Jeff Flinn (jeffrey.flinn_at_[hidden])
Date: 2013-10-03 08:47:04

On 10/3/2013 7:26 AM, Thorsten Ottosen wrote:
> On 02-10-2013 21:14, Matt Calabrese wrote:
>> On Wed, Oct 2, 2013 at 6:07 AM, Thorsten Ottosen <
>> thorsten.ottosen_at_[hidden]> wrote:
>>> It's not only a precondition we are dealing with. It's the postcondition
>>> of the constructor, that is, the invariant of the class. The normal
>>> response to failing to satisfy the postcondition is to throw.
>> This is very often the case when violating any precondition. The
>> answer is
>> that if you don't violate the precondition, then your variants are not
>> violated. What you describe regarding exceptions actually changes your
>> function's preconditions. In other words, the assert version's
>> precondition
>> is that you do not pass a null pointer. The throw version's precondition
>> does not include that constraint at all -- instead, you've made passing a
>> null pointer acceptable, with the behavior being that an exception is
>> thrown in the case that such a pointer is passed.
> So?

So you would never get a failing postcondition without having first
violated the precondition. Any thing after a violated precondition is
suspect. So just assert, IMHO.


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