我使用的是boost::regex_match和boost::string_ref,但是由于模板推断错误,构建失败了,我该如何修复呢?
boost::smatch base;
boost::string_ref sr = "4f000000-4f015000 r-xp 00000000 03:01 12845071 /lib/ld-2.3.2.so";
boost::regex
re(R"(^([[:xdigit:]]+)-([[:xdigit:]]+)\s+..x.\s+([[:xdigit:]]+)\s+\S+:\S+\s+\d+\s+(\S+\.(so|dll|dylib|bundle)((\.\d+)+\w*(\.\d+){0,3})?)$)");
if (boost::regex_match(sr.cbegin(), sr.cend(), base, re)) {
std::cout << base[0] << std::endl;
}
编译器错误:
注:候选人:模板bool boost::regex_match(BidiIterator,BidiIterator,boost::match_results&,const boost::basic_regex&,boost::regex_constants::match_flag_type) bool regex_match(BidiIterator first,BidiIterator last, X=^ /usr/include/boost/regex/v4/regex_match.hpp|44 col 6+注意:模板参数扣减/替换失败: regex.cpp|161 col 58\x注:推导出参数'Iterator‘('const char*’和'__gnu_cxx::__normal_iterator >')的冲突类型
发布于 2019-03-14 03:21:21
boost::smatch
是match_results<std::string::const_iterator>
的别名,所以解决方案:
boost::match_results<boost::string_ref::const_iterator> base;
https://stackoverflow.com/questions/55154414
复制相似问题