#include <iostream> #include <tuple> #include <vector> #include <boost/algorithm/string.hpp> template<typename IT, typename P> auto my_find_if(IT begin, IT end, P& predicate) { while (begin != end) { if (predicate(*begin)) break; ++begin; } return begin; } auto str_equivalence_ignore_case(std::string text) { return [t = std::move(text)](const std::string& s) -> bool { return boost::iequals(s, t); }; } int main() { std::vector<std::string> a = {"hello", "Hallo", "willkommen"}; auto look_for_hello = str_equivalence_ignore_case("hallo"); auto it = my_find_if(a.begin(), a.end(), look_for_hello); std::cout << "my_find_if stopped at: "; if (it != a.end()) { std::cout << "'" << *it << "'"; } else { std::cout << "end"; } std::cout << std::endl; } |