Hi everyone, that you are raising a guru there!
I want to find a specific element in a row vector, ignoring the case:
#include <iostream> #include <string> #include <vector> #include "boost/algorithm/string.hpp" #include "boost/bind.hpp" using std::string; using std::vector; bool icmp(const string& str1, const string& str2) { return boost::iequals(str1, str2); } int main(int argc, char* argv[]) { vector<string> vec; vec.push_back("test"); // if (std::find_if(vec.begin(), vec.end(), boost::bind(&boost::iequals<string,string>, "TEST", _1)) != vec.end()) <-- does not compile if (std::find_if(vec.begin(), vec.end(), boost::bind(&icmp, "TEST", _1)) != vec.end()) std::cout << "found" << std::endl; return 0; }
This still works, but what I would like to know is that if you can get rid of the extra function (icmp ()) and call iequals (the template function) directly (as in a commented line).
Thanks in advance!
source share