frozen
frozen copied to clipboard
map::at() may return incorrect item
map::at() is implemented using at_impl, which itself is:
template <class This, class KeyType>
static inline constexpr auto& at_impl(This&& self, KeyType const &key) {
auto where = self.lower_bound(key);
if (where != self.end())
return where->second;
else
FROZEN_THROW_OR_ABORT(std::out_of_range("unknown key"));
}
So whenever lower_bound
succeeds, it returns the found value. But lower_bound
returns whatever compares not less than - so a check is needed, that it is equal to? Possibly using find_impl
.