
Ion GaztaƱaga <igaztanaga@gmail.com> writes:
Hi David,
But it's not possible to tell is that someone has passed you something nasty when somebody else uses no_throw and you're just getting a reference to the object. That's my whole point. Strong invariants make it possible to develop code separately without adding lots of nasty preconditions everywhere to "ensure" that nobody has given you something nasty.
Well, if the programmer never checks the error of the construction function when he is explicitly requesting a no-throw, the programmer is the problem. So if the programmer requests a new[](std::nothrow) and does not check if the returned pointer is not null, and you receive a null pointer, you have the same problem.
Which is why we assume pointers may be NULL. Not so with references. Everything you've just said misses the point by such a wide margin that I don't know where to begin, and I don't have time to finish right now, so I'll just say this: When a precondition is violated, the programmer that violates it "is the problem." I advocate a system that requires fewer preconditions, and thus offers fewer opportunities for anyone to "be the problem." -- Dave Abrahams Boost Consulting www.boost-consulting.com