I have a vector Modelsas shown below:
struct Model
{
std::string mName;
};
For the string representing the model name, I want to see if I can find one of the models in the vector.
Now I have this:
std::string assetName = "monkey";
std::vector<Model>::iterator iter = std::find_if(mModels.begin(), mModels.end(), boost::bind(&Model::mName, _1) == assetName);
But that does not do random string comparisons. So I read about boost/algorithm/string.hpp, with boost::iequals, which does it right.
Here is my attempt to use it:
std::vector<Model>::iterator iter = std::find_if(mModels.begin(), mModels.end(), boost::iequals(boost::bind(&Model::mName, _1), assetName));
However, this does not compile or report several hundred lines of compilation errors. I believe std :: find_if expects a third param function with only one parameter.
Is there a simple solution for this?
EDIT: I forgot to mention that I can't use C ++ 11, but I can use boost!
EDIT2: The answer below seems to give me this compilation error using this:
std::vector<Model>::iterator iter = std::find_if(mModels.begin(), mModels.end(), boost::bind(&boost::iequals<std::string, std::string>, boost::bind(&Model::mName, _1), assetName));
bind.hpp(69): error C2825: 'F': must be a class or namespace when followed by '::'
2> bind\bind_template.hpp(15) : see reference to class template instantiation 'boost::_bi::result_traits<R,F>' being compiled
2> with
2> [
2> R=boost::_bi::unspecified,
2> F=bool (__cdecl *)(const std::string &,const std::string &,const std::locale &)
2> ]
2> resourcemanifest.cpp(24) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
2> with
2> [
2> R=boost::_bi::unspecified,
2> F=bool (__cdecl *)(const std::string &,const std::string &,const std::locale &),
2> L=boost::_bi::list2<boost::_bi::bind_t<const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,boost::_mfi::dm<std::string,Model>,boost::_bi::list1<boost::arg<1>>>,boost::_bi::value<std::string>>
2> ]