标准库中定义了函数对象:
算数运算:plus<>(),minus<>(),multiplies<>(),divides<>(),negate<>()
关系运算:less<type>(),less_equal<type>(),greater<type>(),greater_equal<>(),equal_to<>(),not_equal_to<>()
逻辑运算:logical_and<>(),logical_or<>(),logical_not<>()
容器中常用函数:
find()函数用来查找容器中某个值,共有三个参数,前两个参数为const_iterator类型用来定义查找的范围,最后一个为想要查找的值,函数的返回值为const_iterator类型,指向查找到的目标元素。
binary_search()函数用来二分查找某个值,共有四个参数,前两个参数为const_iterator类型用来定义查找的范围,第三个元素为想要查找的值,最后一个元素用来指定排序的方式。因为二分查找要求数列是有序的。
transform(sourcestart,sourceend,destinationstart,ops):对容器内的元素从sourcestart到sourceend进行ops操作,然后将计算后的值写入到destinationstart中。