use*_*112 1 c++ iterator stl const stdmap
我有一个方法在地图中找到特定的位置,并通过迭代器引用'返回':
bool Func(const int searchKey, MyMap::iterator& iter) const {
    iter = _map.upper_bound(searchKey);  // Compiler error: comparing non-const iterator and const iterator
    const bool found = iter != _map.begin();
    if(something){
        --_map;
        return true;
    }
    return false;
}
我收到编译器错误,因为std::upper_bound()它返回std::const_iterator并将其与a进行比较std::iterator.
我应该'转换'非常量的返回值upper_bound()吗?