I have a project working fine under MSVS 2010 SP1. I'm trying to convert it to MSVS 2012 RC. I had to change some stuff, mainly related to C++ header/lib paths and MFC custom stuff. But I have one last hurdle to clear.
In MSVC 2010, I'm using a lot of unordered_map<basic_string<TCHAR>, int>
or map<basic_string<TCHAR>, int>
. It compiles fine. But in MSVS 2012, I just get this error:
"The C++ standard doesn't provide a hash for this type"
After searching a bit on the net, I found out that MSVS 2012 should be more close to the C++11 standard, and that the standard only defines hash functions for basic types and 4 defined string types (among them string
and wstring
, but basic_string
not included).
So I changed all basic_string<TCHAR>
to wstring
but to no avail... I still get the same error.
What should I do to be able to compile my app again?
Apparently OOEngineer used basic_string
without including the <string>
header. Part of the functionality might be visible anyway, through indirect includes by other headers.
When VS2010 was released, the then proposed standard put all std::hash<>
specializations in the <functional>
header. In the final C++11 standard it was decided that it was better to put these together with the respective container, so some hash<>
specializations were moved to <string>
, <vector>
, etc.
So, to used all (or any, really) functionality of std::string
, you have to include the <string>
header yourself and not rely on another system header doing so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With