【发布时间】:2022-01-25 15:25:21
【问题描述】:
我有结构:
std::map<:string std::vector> someValues;
如何打印所有值,例如: 1、字符串 2、vector中的值?
我的 c++ 项目中有更多地图,我需要一些循环来打印所有值。
【问题讨论】:
标签: c++ dictionary vector
我有结构:
std::map<:string std::vector> someValues;
如何打印所有值,例如: 1、字符串 2、vector中的值?
我的 c++ 项目中有更多地图,我需要一些循环来打印所有值。
【问题讨论】:
标签: c++ dictionary vector
这可能适用于您想要的。
for (const auto& [key, vec] : someValues) {
std::cout << key << std::endl;
for (const auto& val : vec) {
std::cout << " " << val << std::endl;
}
}
【讨论】: