You can try to implement a common predicate for this, something like these lines (demo here ):
template<class C, class T, T (C::*func)() const> class AttributeEquals { public: AttributeEquals(const T& value) : value(value) {} bool operator()(const C& instance) { return (instance.*func)() == value; } private: const T& value; };
This will require some additional customization, since in your case you are working with pointers, but you are getting a general idea.
source share