Vivek
Vivek

Reputation: 27

‘internalPath’ (type ‘std::string {aka std::basic_string<char>}’) to type ‘std::basic_string<char>&&’

I am running below line of code from a function

string internalPath(os.str());
   m_tags.insert(make_pair<string, TagConfig >(internalPath, tagConfig ));
error: no matching function for call to ‘make_pair(std::string&, const wicom::TagConfig&)’
m_tags.insert(make_pair<string, TagConfig >(internalPath, tagConfig ));
                                                                    ^

Compiler g++=C++14

Upvotes: 2

Views: 731

Answers (1)

You should never specify template arguments expicitly for std::make_pair—it is intended for deducing them, as it uses perfect forwarding. Either get rid of them:

m_tags.insert(make_pair(internalPath, tagConfig ));

or if you need to specify them explicitly, use std::pair directly:

m_tags.insert(pair<string, TagConfig >(internalPath, tagConfig ));

As a side note, you seem to have using namespace std; somewhere. I suggest you get rid of it, it's obfuscation more than anything else.

Upvotes: 3

Related Questions