【适配器】
八种类方法适配器, 将类方法变成函数对象。分别是“const”、“ref”、“单参数”这三种可能性的2^3 = 8。但是记住首两个就够了。
mem_fun_t:最基本形态,最常用之一。
mem_fun_ref_t:加ref,表示传引用,最常用之二。
mem_fun1_t:加1,表示单参数
const_mem_fun_t:加const,表示const函数,不能改变类成员
mem_fun1_ref_t
const_mem_fun_ref_t
const_mem_fun1_t
const_mem_fun1_ref_t
函数指针适配器
ptr_fun:原型
1、pointer_to_unary_function<arg, result>(f),即将一个单参数的函数指针f,其声明为(result)(*f)(arg),变成一个函数子。
2、pointer_to_binary_funcction<arg1, arg2, result>(f),将两参数数指针 (result)(*f)(arg1, arg2),变成函数子 ptr_fun(f)。
其它适配器
binder1st
binder2nd
select1st:这两个什么意思?
select2nd
not1:将单参数函数的返回值取反,例如not1( even<int>() ) 将求偶数的函数子even() 取反,即得奇数。
not2
【逻辑运算】
logical_and
logical_or
logical_not
【比较大小】
equal_to
not_equal_to
less
less_equal
greater
greater_equal
【数学运算】
multiplies:需要加上型别,如 multiplies<double>() // 注意使用时加上括号
divides
minus
plus
modulus
negate
【未分类】
eq_nocase
lt_nocase