map::operator[] (非模板版本) 没有为 rbtree::DoInsertKey(true_type, const_iterator position, const key_type& key) 提供适当的提示
作者: bochsler创建于 2025年12月11日更新于 2025年12月11日
map::operator[] 的两个版本 (map.h 行 184 和 185) 都使用 lower_bound(key) 来检测是否已经存在一个下界,然后尝试将其用作更快插入的提示,都调用了 rbtree 的 base_type::DoInsertKey(true_type(), itLower, key) 或相同的内容,但对于 rvalue 版本使用 eastl::move(key)。DoInsertKey(...) 然后调用 DoGetKeyInsertionPositionUniqueKeysHint(...),以便可能(希望)使用提供的迭代器提示来快速找到父节点,从而实现非常快速的插入。问题在于 DoGetKeyInsertionPositionUniqueKeysHint(...) 期望提示小于传入的键,而 lower_bound 提供的迭代器大于或等于键。
内容来源: electronicarts/EASTL