STL学习----入门(1)[functional]


继续头文件的介绍:
#include < functional >定义了许多函数对象类型和支持函数对象的功能,函数对象是支持operator()()函数调用运算符的任意对象。


function C++11 将任意类型的可调用(Callable)对象与函数调用的特征封装到一起。
mem_fn C++11 将成员函数(Member function)转化成函数对象(指针(Pointer)版)
bad_function_call C++11 这是一个异常,当调用一个空的 function 对象时抛出
is_bind_expression C++11 特征类,识别指定类型是否是一个捆绑表达式
is_placeholder C++11 特征类,识别指定类型是否是一个捆绑表达或中的位置标置符(Bind placeholde)
reference_wrapper C++11 可拷贝构造(CopyConstructible)且可赋值构造(CopyAssignable)的引用封装

哈希

hash 哈希函数对象

hash 函数对内置类型的特例化

   
   
   
   
  • template<> struct hash<bool>;
  • template<> struct hash<char>;
  • template<> struct hash<signed char>;
  • template<> struct hash<unsigned char>;
  • template<> struct hash<char16_t>;
  • template<> struct hash<char32_t>;
  • template<> struct hash<wchar_t>;
  • template<> struct hash<short>;
  • template<> struct hash<unsigned short>;
  • template<> struct hash<int>;
  • template<> struct hash<unsigned int>;
  • template<> struct hash<long>;
  • template<> struct hash<long long>;
  • template<> struct hash<unsigned long>;
  • template<> struct hash<unsigned long long>;
  • template<> struct hash<float>;
  • template<> struct hash<double>;
  • template<> struct hash<long double>;
  • template< class T > struct hash<T*>;

函数

bind C++11 将一至多个参数绑定到函数对象
ref C++11 用从参数推导出的类型创建一个 reference_wrapper 对象
cref C++11 用从参数推导出的类型创建一个 reference_wrapper 对象

函数对象

算述操作

plus 加法函数对象,等价于 x + y
minus 减法函数对象,等价于 x - y
multiplies 乘法函数对象,等价于 x * y
divides 除法函数对象,等价于 x / y
modulus 取模函数对象,等价于 x % y
negate 取相反数函数对象,等价于 -x

比较

equal_to 函数对象,等价于 x == y
not_equal_to 函数对象,等价于 x != y
greater 函数对象,等价于 x > y
less 函数对象,等价于 x < y
greater_equal 函数对象,等价于 x >= y
less_equal 函数对象,等价于 x <= y

逻辑操作

logical_and 函数对象,等价于 x && y
logical_or 函数对象,等价于 x || y
logical_not 函数对象,等价于 !x

按位操作

bit_and 函数对象,等价于 x & y
bit_or 函数对象,等价于 x | y
bit_xor 函数对象,等价于 x ^ y

否认操作

unary_negate 封装函数对象,返回一元谓词(Unary predicate)所表示范围的补(Complement)
binary_negate 封装函数对象,返回二元谓词所表示范围的补
not1 构造自定义 unary_negate 对象
not2 构造自定义 binary_negate 对象

从 C++11 开始弃用的

基类

unary_function 已弃用 用于创建带一个参数的函数对象的基类
binary_function 已弃用 用于创建带两个参数的函数对象的基类

绑定器

binder1st 已弃用 将一个参数绑定到一个二元函数后获得的一元函数对象
binder2nd 已弃用
bind1st 已弃用 将一个参数绑定到一个二元函数
bind2nd 已弃用

函数适配器

pointer_to_unary_function 已弃用 通过一个指针生成一个一元函数对象
pointer_to_binary_function 已弃用 通过一个指针生成一个二元函数对象
ptr_fun 已弃用 将一个函数指针转化成函数对象
mem_fun_t 已弃用 通过一个无参数成员函数生成一个函数对象(指针版)
mem_fun1_t 已弃用 通过一个带一个参数的成员函数生成一个函数对象(指针版)
const_mem_fun_t 已弃用 通过一个 const 限定的无参数成员函数生成一个函数对象(指针版)
const_mem_fun1_t 已弃用 通过一个 const 限定的带一个参数的成员函数生成一个函数对象(指针版)
mem_fun 已弃用 将一个成员函数转化成函数对象(指针版)
mem_fun_ref_t 已弃用 通过一个无参数成员函数生成一个函数对象(引用版)
mem_fun1_ref_t 已弃用 通过一个带一个参数的成员函数生成一个函数对象(引用版)
const_mem_fun_ref_t 已弃用 通过一个 const 限定的无参数成员函数生成一个函数对象(引用版)
const_mem_fun1_ref_t 已弃用 通过一个 const 限定的带一个参数的成员函数生成一个函数对象(引用版)
mem_fun_ref 已弃用


你可能感兴趣的:(STL学习----入门(1)[functional])