C++14 standard defines the find() member functions of std::map
as follows:
iterator find(const key_type& x);
const_iterator find(const key_type& x) const;
Why are these functions not defined as noexcept
? What could possibly go wrong inside, that would require to throw an exception or produce undefined behavior (other than not finding an element in which case the function returns an end
iterator and no exception throwing would be required anyway)?
find()
are based on the Compare()
method of the map, that could throw an exception (imagine the case of a complex key that could be incorrect). So, we can not be sure that find()
won't raise an exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With