Reputation: 6326
I am using boost::regex_match with boost::string_ref, but build failed due to template deduce error, how can I fix it?
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;
}
The compiler error:
/usr/include/boost/regex/v4/regex_match.hpp|44 col 6| note: candidate: template 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,
|| ^
/usr/include/boost/regex/v4/regex_match.hpp|44 col 6| note: template argument deduction/substitution failed:
regex.cpp|161 col 58| note: deduced conflicting types for parameter 'Iterator' ('const char*' and '__gnu_cxx::__normal_iterator >')
Upvotes: 0
Views: 181
Reputation: 6326
boost::smatch
is an alias to match_results<std::string::const_iterator>
, so the solution:
boost::match_results<boost::string_ref::const_iterator> base;
Upvotes: 0