std::plus
来自cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev ">
</tbody><tbody>
</tbody>
| 在标头 <functional> 定义
|
||
template< class T > struct plus; |
(C++14 前) | |
template< class T = void > struct plus; |
(C++14 起) | |
进行加法的函数对象。相当于在两个 T 类型的实例上调用 operator+。
特化
|
标准库在不指定
|
(C++14 起) |
成员类型
| 类型 | 定义 |
result_type (C++17 弃用)(C++20 移除)
|
T
|
first_argument_type (C++17 弃用)(C++20 移除)
|
T
|
second_argument_type (C++17 弃用)(C++20 移除)
|
T
|
|
这些成员类型是通过公开继承 |
(C++11 前) |
成员函数
| 返回两个实参的和 (公开成员函数) |
std::plus::operator()
<tbody> </tbody>T operator()( const T& lhs, const T& rhs ) const; |
(C++14 起为 constexpr) |
|
返回 lhs 与 rhs 的和。
参数
| lhs, rhs | - | 要求和的值 |
返回值
lhs + rhs 的结果。
异常
可能会抛出由实现定义的异常。
可能的实现
constexpr T operator()(const T& lhs, const T& rhs) const
{
return lhs + rhs;
}
|