c++ wcout std::map value
c++ wcout std::map value
我有一个std::map名为'prompts',声明如下:
std::map<const int, wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts;
,它存储int 'key'和wstring 'value'对。如果我这样做:
wcout << prompts[interpreter->get_state()];
编译器(vc10)报错
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)
我必须做些什么来获得从映射返回的wstring值与wcout打印?某种石膏?或者…?
在第一行中,您缺少一个std::
std::map<const int,
std:: wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts;
你应该写std::wcout
而不是wcout
。
我刚刚试了一下这段代码,它可以编译。
#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;
}
相关文章:
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 使用一个考虑到std::map中键值的滚动或换行的键
- 瓦尔格林德:数学函数"Conditional jump or move depends on uninitialised value(s)"
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 允许从 std::map 的密钥窃取资源?
- 为什么static_assert错误:即使我传递常量"expression must have a constant value"?
- 有没有办法对std::unordered_set、std::unrdered_map、std::set、std::map
- 将重物插入std::map
- 使用通用值初始化 std::map,不重复
- 仅包含可移动 std::map 的类的移动构造函数不起作用
- C++:当所有条目都保证是唯一时,替代 std::map
- 如何在PHPCPP库中将C++map<string,map<string>>转换为php::value?
- Visual Studio xtree _STL_VERIFY(this->_Getcont(), "cannot increment value-initialized map/set ite
- "Uninitialised value was created by a stack allocation" 在 C++ 中 std::map
- 将map<key,value>重建为map<value,key的最短/最简单的方法>
- c++ wcout std::map value
- L-value在使用std::map时指定const对象
- 在c++中把map (value,index)转换成vector (index,value)的最快方法是什么?
- C++11 在map<key,value>中存储值(整数和字符串)的多种数据类型的最简单方法?