C++ FAQ Celebrating Twenty-One Years of the C++ FAQ!!!
(Click here for a personal note from Marshall Cline.)
Section 37:
[37.3] How can I find a Fred object in an STL container of Fred* such as std::vector<Fred*>?

STL functions such as std::find_if() help you find a T element in a container of T's. But if you have a container of pointers such as std::vector<Fred*>, these functions will enable you to find an element that matches a given Fred* pointer, but they don't let you find an element that matches a given Fred object.

The solution is to use an optional parameter that specifies the "match" function. The following class template lets you compare the objects on the other end of the dereferenced pointers.

template<typename T>
class DereferencedEqual {
public:
  DereferencedEqual(T const* p) : p_(p) { }
  bool operator() (T const* p2) const { return *p_ == *p2; }
private:
  T const* p_;
};
Now you can use this template to find an appropriate Fred object:
void userCode(std::vector<Fred*> v, Fred const& match)
{
  std::find_if(v.begin(), v.end(), DereferencedEqual<Fred>(&match));
  ...
}