Использование
std::regex_search(input.begin(), input.end(), match, test_reg)
Вызывает перегрузку
template< class BidirIt, class Alloc, class CharT, class Traits >
bool regex_search( BidirIt first, BidirIt last,
std::match_results<BidirIt,Alloc>& m,
const std::basic_regex<CharT,Traits>& e,
std::regex_constants::match_flag_type flags =
std::regex_constants::match_default );
и требует, чтобы match_result
было std::match_results<BidirIt,Alloc>
.В данном случае это std::string::iterator
, но match
, то есть std::smatch
, использует std::string::const_iterator
.Поскольку они не совпадают, компилятор не может определить, на что BidirIt
должен выводить.
Есть много способов обойти это, но самое простое решение - просто использовать перегрузку std::string
, например:
std::regex_search(input, match, test_reg)
( Live Example )