C ++ wcout std :: map value
I have a std :: map called "prompts", which is declared as follows:
std::map<const int, wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts;
and it stores the key and string wstring pairs. If I do this:
wcout << prompts[interpreter->get_state()];
Compiler (vc10) complains
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion)
What do I need to do to get the wstring value returned from the map to print using wcout? Some cast? Or...?
The first line is missing std::
std::map<const int,
std :: wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts;
You should write std::wcout
instead of wcout
.
I just tried this code and compiles.
#include <map> #include <iostream> #include <string> int main() { std::map<const int, std::wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts; std::wcout << prompts[1]; return 0; }