In C++ what would be the simplest way to create a temporary container to store a string and int like the C# dictionary where I can easily match the string key against another string and increase or decrease the entry value int ?
The content of the container would come from a string where each word separated by a space is an key entry, and all values of each key start with 0.
Dictionary<string, int> Options = new Dictionary<string, int>();
Options.Add("xyz", 0);
Options.Add("abc", 0);
Options.Add("dfg", 0);
Then I have to compare it against the user option, something like:
if (Options.ContainsKey(user_opt))
Options[user_opt]++;
I was initially trying something with vectors but since my knowledge with C++ is barely 0 I am mostly stuck’ed at it.
With vectors this is what I got:
vector<string> Options;
boost::split(Options, m_StartMode, boost::is_any_of(" "));
Use
std::maporstd::unordered_mapto store key, value.Then use
map::findto check if key exists: