We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mapped_type& at(const key_type& key) { iterator it = lower_bound(key); // it->first >= key THROW_OUT_OF_RANGE_IF(it == end() || key_comp()(it->first, key), "map<Key, T> no such element exists"); //lower_bound查找的是第一个不小于key的节点,这里应该判断的是key_comp()(key, it->first),如果为false说明key = if->first,那么就可以返回了 return it->second; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
mapped_type& at(const key_type& key)
{
iterator it = lower_bound(key);
// it->first >= key
THROW_OUT_OF_RANGE_IF(it == end() || key_comp()(it->first, key),
"map<Key, T> no such element exists"); //lower_bound查找的是第一个不小于key的节点,这里应该判断的是key_comp()(key, it->first),如果为false说明key = if->first,那么就可以返回了
return it->second;
}
The text was updated successfully, but these errors were encountered: