返回两个参数的和,等价于符号“+”的作用,如果是累的话,必须重定义。
基本介绍
- 外文名:plus
plus在C++库中的定义如下:
template<>
struct plus<void>
{ // transparent functor for operator+
typedef int is_transparent;
template<class _Ty1,
class _Ty2>
constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
-> decltype(static_cast<_Ty1&&>(_Left)
+ static_cast<_Ty2&&>(_Right))
{ // transparently apply operator+ to operands
return (static_cast<_Ty1&&>(_Left)
+ static_cast<_Ty2&&>(_Right));
}
};