4

Today I wanted to try to bring my project from visual c++ 2010 to visual c++ 2013.

I get this error in visual c++ 2013 which I did not get when compiling with 2010 version.

//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));
}

the error is:

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 *&&'

what am I doing wrong? Why I did not get any error in vc++ 2010?

Thanks

Marco
  • 319
  • 1
  • 5
  • 15

1 Answers1

11

Change

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

to

Object_list.insert(std::make_pair(Object_name, Object_pointer));
drescherjm
  • 10,365
  • 5
  • 44
  • 64
  • 1
    For a better description why this is required look here: http://stackoverflow.com/questions/9641960/c11-make-pair-with-specified-template-parameters-doesnt-compile – drescherjm Oct 19 '13 at 13:36
  • @Marco see my comment added a few seconds before your last comment. – drescherjm Oct 19 '13 at 13:38