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)?
Compare
function of a map have to be noexept, so I don't thinkfind()
could be noexept since it compare keys – CowellCompare
can throw indeed:23.2.4.1.1
of C++14 stateserase(k) does not throw an exception unless that exception is thrown by the container’s Compare object (if any).
Please make your comment an answer. – Haileyhailfellowwellmetnoexcept(Compare)
is still an option. – Miticide