I need help using unsigned char
s in std::vector
s that are inside of a std::map
.
This is how I declare the std::map
:
std::map<int, std::vector<unsigned char>> DataMap;
The problem comes when I try to assign a std::vector
to the std::map
.
it->first
comes from another std::map
, as this code is inside a loop.
std::vector<unsigned char> charHolder;
for(int i = 0; i < 10; i++)
{
charHolder.push_back('2');
}
DataMap.insert(std::pair<int, std::vector<unsigned char>(it->first, charHolder));
The errors:
Template argument 2 is invalid
I need to assigned a char[]
array to the 2
place in the std::map
. I've tried an array, but I had no luck.
You are missing a >
character
DataMap.insert (std::pair<int, std::vector<unsigned char>>(it->first, charHolder));
^
You may use uniform initializer as following:
DataMap.insert ({it->first, charHolder});