From: Mikko Rasa Date: Tue, 20 Dec 2022 23:31:12 +0000 (+0200) Subject: Partially revert "Use braced initializer lists ..." X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=bfec7aaf287308f53da56970b4f5cd91ef7f3b2a;p=libs%2Fcore.git Partially revert "Use braced initializer lists ..." Turns out you can't omit initializers with some members, and MemberCompare has the predicate as a member. --- 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