无法将参数1从int转换为int &&错误

4
今天我想尝试将我的项目从Visual C++ 2010迁移到Visual C++ 2013。
在Visual C++ 2013中编译时,我遇到了这个错误,但在使用2010版本进行编译时却没有出现这个错误。
//somewhere in the SimpleObject_list class
std::unordered_map<std::string, SimpleObject *> Object_list; 


//method which is giving me the error
void SimpleObject_list::Add(const char *Object_name, SimpleObject * Object_pointer){
    cout << "SimpleObject listed as: " << Object_name << endl;
    Object_list.insert(std::make_pair<std::string,SimpleObject *>(Object_name, Object_pointer));
}

错误是:
error C2664: 'std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char>>,SimpleObject *> std::make_pair<std::string,SimpleObject*>(_Ty1 &&,_Ty2 &&)' : cannot convert argument 2 from 'SimpleObject *' to 'SimpleObject *&&'

我做错了什么?为什么在vc++ 2010中没有收到任何错误提示?谢谢。
1个回答

11

更改

Object_list.insert(std::make_pair<std::string,SimpleObject *>(Object_name, Object_pointer));

Object_list.insert(std::make_pair(Object_name, Object_pointer));

1
为了更好地描述为什么需要这个,请查看这里:https://dev59.com/T2kw5IYBdhLWcg3wzdpE - drescherjm
@Marco,在你最后一条评论几秒钟之前,我添加了一条评论,请查看。 - drescherjm

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接