boost regex格式化程序,如何使用自定义函数
boost regex formatter, how to use a custom function
调用boost::regex_replace时,如何调用自定义格式化函数?
我的代码如下:
template <typename T>
std::string fmt(boost::match_results<T> match) {
auto str = match[1];
if (str == ".") {
return ""."";
} else {
return str;
}
}
void __ConvertEscapeChar(std::string& action, std::string regex) {
boost::regex re(regex);
action = boost::regex_replace(action, re, &fmt, boost::regex_constants::match_all);
}
然而,它显示了一个错误,"无法推导__fmt的模板参数"。-事实上T是什么?
除非您出于某种原因需要在fmt
函数中灵活使用模板,否则请尝试以下操作:
std::string fmt(boost::smatch match)
相关文章:
- 使用自定义比较函数使用std::sort()对矢量字符串进行排序时出现问题
- 使用自定义比较函数在类内进行列表排序
- 通过函数指针对类内的 STL SET 使用自定义比较器
- 如何创建函数可能使用自定义可比C++?
- 使用自定义工具集获取动态退出析构函数链接错误 - eh 矢量析构函数
- 如何将CString转换为使用WCHAR的Windows API和自定义函数?
- 关于如何在 std::sort 和 std::p riority_queue 中使用自定义比较函数的困惑
- 伯克利数据库 Db->get 使用自定义比较函数时不起作用
- 使用自定义删除器返回unique_ptr的工厂函数
- 使用自定义 QSortFilterProxyModel 覆盖哪些函数
- 如何使用C 代码调用MATLAB自定义函数
- 使用自定义比较函数进行C 排序
- C 需要使用自定义构造函数的帮助
- 使用自定义析构函数时出现"Undefined reference"错误
- 如何使用自定义分配器创建std::函数
- 使用自定义构造函数作为模板函数
- 如何使用自定义修改的v8::参数调用v8::函数
- C++std::使用自定义函数进行排序
- boost regex格式化程序,如何使用自定义函数
- 使用自定义函数对象比较器 c++ 设置