Reputation: 529
I tried to use:
std::map<std::wstring, std::pair<std::wstring, INT_PTR>> mm;
**mm.insert(_T("name"), std::make_pair(_T("value1"), static_cast<INT_PTR>(1));**
What is wrong with that?
If I use this:
mm[_T("name")] = std::make_pair(_T("value1"), static_cast<INT_PTR>(1));
it works.
The error is this:
No constructor could take the source type, or constructor overload resolution was ambiguous
The same with that:
std::map<std::wstring, std::vector<std::pair<std::wstring, INT_PTR>>> mm;
std::vector <std::pair<std::wstring, INT_PTR>> vec;
vec.push_back(std::make_pair(_T("value1"), static_cast<INT_PTR>(1)));
mm.insert(_T("name"), vec);
Why does it work with "insert_or_assign" like this?
mm.insert_or_assign(_T("name"), vec);
Upvotes: 2
Views: 86
Reputation: 10756
std::map::insert simply doesn't take the two parameters that you're attempting. It takes a one-parameter key-value pair.
mm.insert(std::make_pair(_T("name"), std::make_pair(_T("value1"), static_cast<INT_PTR>(1))));
std::map::insert_or_assign on the other hand does take the two parameters you're attempting.
Upvotes: 5