|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Old binders and adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <functional> | ||
template<> class negate<void>; | (since C++14) | |
std::negate<> is a specialization ofstd::negate with parameter and return type deduced.
Contents |
| Type | Definition |
is_transparent | unspecified |
operator() | returns its negated argument (public member function) |
template<class T> constexprauto operator()( T&& arg)const | ||
Returns the result of negatingarg.
| arg | - | value to negate |
-std::forward<T>(arg).
#include <complex>#include <functional>#include <iostream> int main(){auto complex_negate=std::negate<void>{};// “void” can be omittedconstexprstd::complex z(4,2);std::cout<< z<<'\n';std::cout<<-z<<'\n';std::cout<< complex_negate(z)<<'\n';}
Output:
(4,2)(-4,-2)(-4,-2)