首页 > 其他 > 详细

一元“++”:“_Iter”不定义该运算符或到预定义运算符可接收类型的转换

时间:2020-04-03 01:17:58      阅读:361      评论:0      收藏:0      [点我收藏+]

【1】复现编译错误

C2675: 一元“++”:“_Iter”不定义该运算符或到预定义运算符可接收类型的转换

 1 #include <map>
 2 #include <unordered_map>
 3 
 4 struct GJGActionEvent
 5 {
 6     std::map<std::string, std::string> input;
 7     std::unordered_map<std::string, std::string> output;
 8 };
 9 
10 int main()
11 {
12     std::string key = "input";
13     std::string value = "100";
14     GJGActionEvent actEvt;
15     actEvt.input.insert(key, value);     // error:C2675
16     actEvt.output.insert(key, value);    // eroor:C2675
17 
18     return 0;
19 }

技术分享图片

【2】解决方法

代码如下:

 1 #include <map>
 2 #include <unordered_map>
 3 
 4 struct GJGActionEvent
 5 {
 6     std::map<std::string, std::string> input;
 7     std::unordered_map<std::string, std::string> output;
 8 };
 9 
10 int main()
11 {
12     std::string key = "input";
13     std::string value = "100";
14     GJGActionEvent actEvt;
15 //  actEvt.input.insert(key, value);     // error:C2675
16 //  actEvt.output.insert(key, value);    // eroor:C2675
17 
18     actEvt.input.insert(std::make_pair(key, value));   // OK
19     actEvt.output.insert(std::make_pair(key, value));  // OK
20 
21     return 0;
22 }

 

一元“++”:“_Iter”不定义该运算符或到预定义运算符可接收类型的转换

原文:https://www.cnblogs.com/Braveliu/p/12624006.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!