On Thu, Oct 3, 2013 at 8:59 AM, Thorsten Ottosen < thorsten.ottosen@dezide.com> wrote:
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 functionality.
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