std::negate<void>
來自 cppreference.com
定義於標頭檔案 <functional> |
||
template<> class negate<void>; |
(C++14 起) | |
std::negate<> 是 std::negate 的特化,其引數和返回型別被推導。
目錄 |
[編輯] 成員型別
型別 | 定義 |
is_transparent
|
未指定 |
[編輯] 成員函式
operator() |
返回其取反的引數 (公開成員函式) |
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)