std::negate<void>
From cppreference.com
< cpp | utility | functional
| ヘッダ <functional> で定義 |
||
| template<> class negate<void>; |
(C++14以降) | |
std::negate<> は、パラメータと戻り値の型が推論される std::negate の特殊化です。
目次 |
[編集] メンバ型
| 型 | 定義 |
is_transparent
|
unspecified |
[編集] メンバ関数
| operator() |
引数を否定した結果を返します。 (public member function) |
std::negate<void>::operator()
| template< class T > constexpr auto operator()( T&& arg ) const |
||
arg を否定した結果を返します。
パラメータ
| arg | - | 否定する値 |
戻り値
-std::forward<T>(arg).
[編集] 例
このコードを実行
#include <complex> #include <functional> #include <iostream> int main() { auto complex_negate = std::negate<void>{}; // “void” can be omitted constexpr std::complex z(4, 2); std::cout << z << '\n'; std::cout << -z << '\n'; std::cout << complex_negate(z) << '\n'; }
出力
(4,2) (-4,-2) (-4,-2)