
Given: // Definitions class Element { public: const std::string &GetTag() const; }; typedef std::vector<Element> ElementContainer; // Now here is what is required ElementContainer elements; ... ElementContainer matchingElements; std::string matchingTag("abc"); copy_if(elements.begin(),elements.end(),back_inserter(matchingElements)),pred); -- What is pred? Assuming that iElements represents the iterator inside copy_if, pred should be something like: iElements->GetTag()==matchingTag I could go about this by creating a new function object class/struct, which takes matchingTag as its sole constructor argument and does the comparison inside operator(). But, I want to use in place composition using binders, etc... to create the pred, so as not to have to create a function object class/struct. The question is, "What piece of code should pred be?" // Almost does the right thing, but it's only *iElements==matchingTag, I need iElements->GetTag()==matchingTag bind_2nd(equal_to,matchingTag) This seems like a very common operation. How can I compose the predicate, in place to do this? If there are multiple solutions, I would like to hear them as well! Thanks, Michael