【发布时间】:2017-01-26 02:43:30
【问题描述】:
我想创建std::string,其中包含std::map<std::string, std::string> 的第一个元素,由一些分隔符分隔(它可以来自STL 或Boost)。
有没有比循环更好的解决方案(一行)?就像boost::algorithm::join 为std::vector<std::string>。
【问题讨论】:
-
不清楚。假设您有一个包含两个元素的地图。您正在寻找的输出类似于“key1 : value1, key2 : value2”?
-
见How to retrieve all keys (or values) from a std::map?,修改解决方案追加到字符串
-
不,@Rerito。对于:“key1:value1,key2:value2”和逗号分隔符我想要:“key1,key2”。
标签: c++ string c++11 dictionary boost