From: Mikko Rasa Date: Wed, 26 Oct 2022 08:52:12 +0000 (+0300) Subject: Use std::less as predicate in algorithms X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=01844ee2ba101c25655dd5eacf62ca9365f26f21 Use std::less as predicate in algorithms It guarantees a consistent ordering of pointers, unlike the < operator. --- diff --git a/source/core/algorithm.h b/source/core/algorithm.h index 51c2369..d295d00 100644 --- a/source/core/algorithm.h +++ b/source/core/algorithm.h @@ -2,6 +2,7 @@ #define MSP_CORE_ALGORITHM_H_ #include +#include namespace Msp { @@ -124,16 +125,17 @@ inline typename Container::const_iterator find_member(const Container &cont, con return find_if(cont, MemberMatch(value, mp)); } -template +template> 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