From 01844ee2ba101c25655dd5eacf62ca9365f26f21 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 26 Oct 2022 11:52:12 +0300 Subject: [PATCH] Use std::less as predicate in algorithms It guarantees a consistent ordering of pointers, unlike the < operator. --- source/core/algorithm.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 -- 2.43.0