2

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@trideceth12 "it is intended for deducing them, as it uses perfect forwarding." It cannot deduce them for perfect forwarding if you specify them explicitly. The only difference between using std::pair and std::make_pair is whether you specify template arguments or not. If you want to specify them explicitly, use std::pair.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.