On 4 Oct 2013 at 9:45, Eric Niebler wrote:
This is the crux of it. If this condition really does represent a programmer error (and IMO in this case it does), then Matt is right. Throwing is wrong. Programmer error == bug == your program is already in some weird state. Continuing by throwing an exception and executing an arbitrary amount of code is not good.
Precondition violations ==> assertions. Use BOOST_ASSERT. That gives people a way to hook the behavior while giving a sane default.
Agreed. Fatal, insta-kill exceptions are underused in C++. I tend to sprinkle checks for "impossible" state all over my code with insta-kill fatal exception termination if they occur. They're very handy for detecting race conditions/memory corruption/bugs in mine or third party code. Niall -- Currently unemployed and looking for work. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/