#define MSP_CORE_ALGORITHM_H_
#include <algorithm>
+#include <functional>
namespace Msp {
return find_if(cont, MemberMatch<typename Container::value_type, T>(value, mp));
}
-template<typename C, typename T>
+template<typename C, typename T, typename P=std::less<T>>
struct MemberCompare
{
T C::*mem_ptr;
+ P pred;
MemberCompare(T C::*p): mem_ptr(p) { }
- bool operator()(const C &obj, const T &v) { return obj.*mem_ptr<v; }
- bool operator()(const T &v, const C &obj) { return v<obj.*mem_ptr; }
- bool operator()(const C &obj1, const C &obj2) { return obj1.*mem_ptr<obj2.*mem_ptr; }
+ bool operator()(const C &obj, const T &v) { return pred(obj.*mem_ptr, v); }
+ bool operator()(const T &v, const C &obj) { return pred(v, obj.*mem_ptr); }
+ bool operator()(const C &obj1, const C &obj2) { return pred(obj1.*mem_ptr, obj2.*mem_ptr); }
};
template<typename Container, typename T>