C++11 map erase lambda编译出错

zhousitiaoda 2015-08-08 12:00:34

std::map<CString,CString> mapCheck;
mapCheck.erase(std::remove_if(mapCheck.begin(),mapCheck.end(),[&](const std::pair<CString,CString>& item)
{
return TRUE;
}),mapCheck.end());

请教下,编译出错,没太明白
error C2678: 二进制“=”: 没有找到接受“const ATL::CString”类型的左操作数的运算符(或没有可接受的转换)

把CString换成int,OK,把map换成vector,OK,请教下大神。。
...全文
88 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiqiang01234 2015-08-08
  • 打赏
  • 举报
回复
已经有erase了,还要remove_if(),是什么意思?
zhousitiaoda 2015-08-08
  • 打赏
  • 举报
回复
已解决,为方便后人还是贴下原因: the similarly-named container member functions list::remove, list::remove_if, forward_list::remove, and forward_list::remove_if erase the removed elements. These algorithms cannot be used with associative containers such as std::set and std::map because ForwardIt does not dereference to a MoveAssignable type (the keys in these containers are not modifiable

64,636

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧