关于 map 的迭代器

 

今天遇到一个问题

CountCompileResult(const LIST_MAP & rfLmCompileWafers)
{
  

    for (auto itr = rfLmCompileWafers.begin(); itr != rfLmCompileWafers.end(); ++itr)
    {
        if ((*itr)["DEST_TYPE"].compare(GRADE_1) == 0 || (*itr)["DEST_TYPE"].compare(GRADE_2) == 0 ||
            (*itr)["DEST_TYPE"].compare(GRADE_3) == 0)
    }
 
}
 
当传参类型为 const 时,重载 [] 运算符不能使用,去掉const 可以正常编译,因为不存在const 类型的重载。
 
 
posted on 2022-08-24 18:59  皖南  阅读(41)  评论(0)    收藏  举报