定义

  1. template< class T = void >
  2. struct plus;
  3. T operator()( const T& lhs, const T& rhs ) const;
  4. (until C++14)
  5. constexpr T operator()( const T& lhs, const T& rhs ) const;
  6. (since C++14)

这里的就重载了函数运算符

示例

  1. #include"Complex.h"
  2. #include<algorithm>
  3. #include<functional>
  4. #include<iostream>
  5. using namespace std;
  6. int main() {
  7. const int a = 1;
  8. const int b = 2;
  9. plus<int> c;
  10. cout << c(a, b) << endl;
  11. }