From bfec7aaf287308f53da56970b4f5cd91ef7f3b2a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 21 Dec 2022 01:31:12 +0200 Subject: [PATCH] Partially revert "Use braced initializer lists ..." Turns out you can't omit initializers with some members, and MemberCompare has the predicate as a member. --- source/core/algorithm.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/core/algorithm.h b/source/core/algorithm.h index 30ca267..43bbaee 100644 --- a/source/core/algorithm.h +++ b/source/core/algorithm.h @@ -143,6 +143,8 @@ struct MemberCompare T C::*mem_ptr; P pred; + MemberCompare(T C::*p): mem_ptr(p) { } + 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); } @@ -151,37 +153,37 @@ struct MemberCompare template inline typename Container::iterator lower_bound_member(Container &cont, const T &value, T Container::value_type::*mp) { - return lower_bound(cont, value, MemberCompare{ mp }); + return lower_bound(cont, value, MemberCompare(mp)); } template inline typename Container::const_iterator lower_bound_member(const Container &cont, const T &value, T Container::value_type::*mp) { - return lower_bound(cont, value, MemberCompare{ mp }); + return lower_bound(cont, value, MemberCompare(mp)); } template inline typename Container::iterator upper_bound_member(Container &cont, const T &value, T Container::value_type::*mp) { - return upper_bound(cont, value, MemberCompare{ mp }); + return upper_bound(cont, value, MemberCompare(mp)); } template inline typename Container::const_iterator upper_bound_member(const Container &cont, const T &value, T Container::value_type::*mp) { - return upper_bound(cont, value, MemberCompare{ mp }); + return upper_bound(cont, value, MemberCompare(mp)); } template inline void sort_member(Container &cont, T Container::value_type::*mp) { - sort(cont, MemberCompare{ mp }); + sort(cont, MemberCompare(mp)); } template inline void stable_sort_member(Container &cont, T Container::value_type::*mp) { - stable_sort(cont, MemberCompare{ mp }); + stable_sort(cont, MemberCompare(mp)); } template -- 2.45.2