
Hi Artyom, Artyom wrote:
Mathias Gaunard wrote:
Definitely a no-no. Dereferencing an invalid iterator is a programming error, not an exceptional situation.
The thing to use is an assertion. I'm sorry but as far as I remember nobody deprecated std::logic_error (and std::out_of_range derived from it).
Small point, when you program some mission critical systems and services you don't want the process to go down for something that maybe only a single response can go down that way. This is very important for some mission critical code (and I had written such code not once).
For that reason one can specify a different behavior for BOOST_ASSERT to invoke when it fails - throw std::logic_error, log somewhere, whatever. For ordinary programs, I definitely want a programmer error to result in an immediate termination of the program, which is what I get from BOOST_ASSERT by default. However when writing a mission critical system one can easily make BOOST_ASSERT to do something else, as appropriate for the project. So my point is that I see no reason for BOOST_ASSERT not to be used here. Best Regards, Gevorg