std::negate
来自 zh.cppreference.net
| 定义于头文件 <functional>
|
||
template< class T >
struct negate;
|
(至 C++14) | |
template< class T = void >
struct negate;
|
(自 C++14) | |
用于执行求负的函数对象。实际上对类型 operator- 的实例调用 operator-。T
特化
|
当未指定
|
(C++14 起) |
成员类型
| 类型 | 定义 |
result_type
(C++17 中弃用)
(C++20 中移除)
|
T
|
argument_type
(C++17 中弃用)
(C++20 中移除)
|
T
|
|
这些成员类型通过公开继承 std:: unary_function < T, T > 获得。 |
(until C++11) |
成员函数
|
operator()
|
返回参数的逻辑非结果
(公开成员函数) |
std::negate:: operator()
|
T operator
(
)
(
const
T
&
arg
)
const
;
|
(constexpr since C++14) | |
返回 arg 的负值。
参数
| arg | - | 需要计算负值的参数 |
返回值
- arg 的结果。
异常
可能抛出由实现定义的异常。
可能的实现
constexpr T operator()(const T& arg) const
{
return -arg;
}
|