charlie

@abilitytao
可以使用policy based做比较

template<typename element_t>
struct less_than {
static bool compare(const element_t lhs, const element_t rhs) {
return lhs<rhs;
}
};

template<typename element_t, typename cmp_policy = less_than<element_t> >
struct sort_wirzad {
void easy_sort() {
...
//做比较
if ( cmp_policy::compare(e1,e2) ) { /* do sth */ }
}
};

用户可以自定义自己的 compare_policy
比如定义一个 greater_than 可以这样传递给sort_wizard:

sort_wizard<int,greater_than> instance;
re: static member function charlie 2006-11-02 19:38
朋友,不是说坚持到底吗?怎么停了?

导航

<2026年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

统计

常用链接

留言簿

搜索

最新评论