本文介绍了提高::算法::包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看着模板定义以及参数似乎想通过一系列和predicate迭代器。我在一个vector.begin(通过),...端(),并为std :: string predicate但仍获得提振相关库项目的主持人很多编译时错误。我可以看到使用的boost ::算法的一个明显的例子::包含好吗?
I looked at the template definition and the parameters appear to want iterators across a range and a predicate. I passed in a vector.begin(), ...end(), and a std::string predicate but still get many compile time errors related a host of boost library items. Can I see a clear example of the use of boost::algorithm::contains please?
推荐答案
这是相当简单的,我猜你是通过迭代器时,你应该传递容器。
It's fairly simple, I guess you are passing iterators when you should be passing containers.
std::string s = "fishing";
std::cout << boost::algorithm::contains(s, "is") << std::endl;
std::vector<int> v {1,2,3,5,7,2,7,4,5,8};
std::vector<int> v2 {5,7,2,7,4};
std::vector<int> v3 {5,7,2,7,3};
std::cout << boost::algorithm::contains(v, v2) << std::endl;
std::cout << boost::algorithm::contains(v, v3) << std::endl;
这篇关于提高::算法::包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!