我想把 std::boyer_moore_searcher 作为参数传递,封装了这个函数
std::string_view::size_type
search_sv(std::string_view sv, const std::boyer_moore_searcher<std::string_view>& searcher)
{
auto it = std::search(sv.begin(), sv.end(), searcher);
if (it == sv.end())
{
return std::string_view::npos;
}
return (it - sv.begin());
}
但是下面两种方式调用都出错,应该咋整?
const std::string_view contents = "1111abc22222";
const std::string_view sv = "abc";
const std::boyer_moore_searcher<std::string_view> searcher(sv.begin(), sv.end());
auto pos = search_sv(contents, searcher);
const std::string_view contents = "1111abc22222";
const std::string_view sv = "abc";
const std::boyer_moore_searcher searcher(sv.begin(), sv.end());
auto pos = search_sv(contents, searcher);
--
FROM 218.76.62.*