std::negate<void>

< cpp‎ | utility‎ | functional
定义于头文件 <functional>
template<>
class negate<void>;
(C++14 起)

std::negate<>std::negate 的特化,其参数与返回类型留待推导。

成员类型

成员类型 定义
is_transparent /* 未指定 */

成员函数

operator()
返回其负的参数
(公开成员函数)

std::negate<>::operator()

template< class T >

constexpr auto operator()( T&& arg ) const

  -> decltype(-std::forward<T>(arg));

返回对 arg 求负的结果(或重载的 operator- 之所为)。

参数

arg - 要求负的值

返回值

-arg 的结果。

注意

成员类型 is_transparent 指示调用方,此函数对象是一个通透函数对象:它接受任意类型的参数并使用完美转发,这在将函数对象在多种语境中,或以右值参数使用时,避免不需要的复制和转换。特别是,诸如 std::set::findstd::set::lower_bound 的模板函数在其 Compare 类型上使用此类型。

示例