const T &value;
T C::*mem_ptr;
- MemberMatch(const T &v, T C::*p): value(v), mem_ptr(p) { }
-
bool operator()(const C &obj) { return obj.*mem_ptr==value; }
};
template<typename Container, typename T>
inline typename Container::iterator find_member(Container &cont, const T &value, T Container::value_type::*mp)
{
- return find_if(cont, MemberMatch<typename Container::value_type, T>(value, mp));
+ return find_if(cont, MemberMatch<typename Container::value_type, T>{ value, mp });
}
template<typename Container, typename T>
inline typename Container::const_iterator find_member(const Container &cont, const T &value, T Container::value_type::*mp)
{
- return find_if(cont, MemberMatch<typename Container::value_type, T>(value, mp));
+ return find_if(cont, MemberMatch<typename Container::value_type, T>{ value, mp });
}
template<typename C, typename T, typename P=std::less<T>>
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); }
template<typename Container, typename T>
inline typename Container::iterator lower_bound_member(Container &cont, const T &value, T Container::value_type::*mp)
{
- return lower_bound(cont, value, MemberCompare<typename Container::value_type, T>(mp));
+ return lower_bound(cont, value, MemberCompare<typename Container::value_type, T>{ mp });
}
template<typename Container, typename T>
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<typename Container::value_type, T>(mp));
+ return lower_bound(cont, value, MemberCompare<typename Container::value_type, T>{ mp });
}
template<typename Container, typename T>
inline typename Container::iterator upper_bound_member(Container &cont, const T &value, T Container::value_type::*mp)
{
- return upper_bound(cont, value, MemberCompare<typename Container::value_type, T>(mp));
+ return upper_bound(cont, value, MemberCompare<typename Container::value_type, T>{ mp });
}
template<typename Container, typename T>
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<typename Container::value_type, T>(mp));
+ return upper_bound(cont, value, MemberCompare<typename Container::value_type, T>{ mp });
}
template<typename Container, typename T>
inline void sort_member(Container &cont, T Container::value_type::*mp)
{
- sort(cont, MemberCompare<typename Container::value_type, T>(mp));
+ sort(cont, MemberCompare<typename Container::value_type, T>{ mp });
}
template<typename Container, typename T>
inline void stable_sort_member(Container &cont, T Container::value_type::*mp)
{
- stable_sort(cont, MemberCompare<typename Container::value_type, T>(mp));
+ stable_sort(cont, MemberCompare<typename Container::value_type, T>{ mp });
}
template<typename Container, typename Predicate>