Reputation: 1305
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...?
Upvotes: 4
Views: 257
Reputation: 9060
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::wcout
instead of wcout
.
I just tried this code and it 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;
}
Upvotes: 1