how to insert vector object into the map using C++

  • Thread starter Thread starter John paul coder
  • Start date Start date
J

John paul coder

Guest
Hello All,

My requirement is to insert vector object into the map. But, when trying to insert vector object into the map getting the below error.

no instance of overloaded function "std::map<_Kty, _Ty, _Pr, _Alloc>::insert [with _Kty=std::wstring, _Ty=std::wstring, _Pr=std::less<std::wstring>, _Alloc=std::allocator<std::pair<const std::wstring, std::wstring>>]" matches the argument list

Could someone help me how to insert vector object into the map?

#include "stdafx.h"
#include <vector>
#include <iostream>
#include <map>
using namespace std;

int main()
{
std::vector<std::wstring> Locations;
std::map<std::wstring, std::wstring> m_params;

m_params.insert({ L"emailType" , L"email" });
m_params.insert({ L"emailLocation" , Locations }); //Here I am getting an error

for (auto itr = m_params.begin(); itr != m_params.end(); ++itr)
{

}
return 0;
}

Continue reading...
 
Back
Top