1 //针对类中某一对象比较'<'
2 template<class V, class T>
3 struct lt_pred{
4 lt_pred(V T::*_pm){pm=_pm;}
5 V T::*pm;
6 bool operator()(const T& a, const T& b){
7 return a.*pm < b.*pm;
8 }
9 };
10
11 template<class V, class T>
12 lt_pred<V,T> create_lt_pred(V T::*pm){//自动推倒参数用
13 return lt_pred<V,T>(pm);
14 }
15
16 //sort(ha,ha+3, create_lt_pred(&hasintmember::a));