I declared std: map below:
std::map<std::string, std::set<unsigned char*>> FilesMap;
int InsertData(unsigned char* name)
{
// here i try to insert pair with name above and clear std::set
FilesMap.insert(std::pair<std::string, std::set<unsigned char*>>(std::string((char*)name), std::set<unsigned char*>()));
}
But I have many errors like:
Error 16 error C2676: binary '<': 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator c: \program files (x86)\microsoft Visual Studio 10.0\vc\include\xfunctional
What am I doing wrong?
First of all, this horribly long line
FilesMap.insert(std::pair<std::string, std::set<unsigned char*>>(std::string((char*)name), std::set<unsigned char*>()));
can be simplified if you use std::make_pair function, which will deduce template arguments.
FilesMap.insert(std::make_pair(std::string(reinterpret_cast<char*>name)), std::set<unsigned char*>()));
Second, you could make a typedef for your set so as to simplify the above line even more
typedef std::set<unsigned char*> mySetType;
std::map<std::string, mySetType>> FilesMap;
FilesMap.insert(std::make_pair(std::string(reinterpret_cast<char*>name)), MySetType()));
And lastly, and most importantly, I believe the reason that the compiler is unable to find a suitable operator <
for std::string is that you forgot to #include<string>