Subject: Re: [boost] Looking for thoughts on a new smart pointer: shared_ptr_nonnull
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2013-10-03 16:01:22
On Thu, Oct 3, 2013 at 8:59 AM, Thorsten Ottosen <
> I can't create a broken std::vector by means of the constructor. At least
> I don't know how to. WhenI think about it, std::string can crash if you
> pass it null_ptr. Has anybody profitted from that? It leads to
> subtle run-time bugs, and I ran into that a few months back.
I think it's just clear that we have some ideological differences here.
std::string should not be checking for null as a part of its documented
> It's pretty easy to come up with examples -- again, any
>> function with specified preconditions can do potentially this.
> It's not just any function. It's the constructor.
Yeah, and? That doesn't change anything. Any function, including
constructors, can put your object into a state with broken invariants if
you violate a precondition because it's UB. Constructor or any other
function makes no difference.
>> You forget that some people prefer to provide a nice log message and warn
> the users in a nice way instead of crashing the program.
If it's decided that that is what's important, then that's fine.
-- -Matt Calabrese
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk