I have a std::map called ‘prompts’ which is declared like this:
std::map<const int, wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts;
and it stores int ‘key’ and wstring ‘value’ pairs. If I do this:
wcout << prompts[interpreter->get_state()];
The 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 have to do to get the wstring value returned from the map to print with wcout? Some sort of cast? Or…?
In the first line, you are missing an
std::std::map<const int,std::wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts;You should write
std::wcoutinstead ofwcout.I just tried this code and it compiles.