Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 722 Bytes

File metadata and controls

27 lines (20 loc) · 722 Bytes

functional

仿函数(Functor)又称为函数对象(Function Object),是一个能行使函数功能的类。 在<functional>头文件中定义了如下三类仿函数:

✏ 1、算术类仿函数

操作 仿函数
plus<T>
minus<T>
multiplies<T>
divides<T>
取模 modulus<T>
取反 negate<T>

定义:

template< class T >
struct plus;  // (C++14 前)
template< class T = void >
struct plus;  // (C++14 起)

T operator()( const T& lhs, const T& rhs ) const;           // (C++14 前)
constexpr T operator()( const T& lhs, const T& rhs ) const; // (C++14 起)