我知道可以使用 boost escaped_list_separator 拆分字符串并同时删除转义。
是否有类似(优雅)的方式来实现相反的结果?就像在添加转义符的同时将多个字符串合并为一个?
最佳答案
我知道你想要单线,但找不到满足你需求的东西。
使用 string escape(const string &s)
函数,您可以编写自己的单行代码:
#include <algorithm>
string escape(const string &s)
{
// Do your thing.
return result;
}
string joinEscaped(const vector<string> &v, const string &delimiter)
{
std::vector<string> temp(v.size());
std::transform(v.begin(), v.end(), temp.begin(), escape);
return boost::algorithm::join(temp, delimiter);
}
关于c++ - 是否有一些 escaped_list_separator 反向函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21023316/