A unary function object that returns the negation of its operand.
Standards<ToolKit>
#include <functional> template< class T > struct negate : unary_function< T, T >
-
#include <iostream> #include <algorithm> #include <functional> int input[ 3 ] = { 1, 2, 3 }; void main() { int output[ 3 ]; transform( input, input + 3, output, negate< int >() ); for ( int i = 0; i < 3; ++i ) cout << output[ i ] << "\n"; } -1 -2 -3
Copyright©1994-2026 Recursion Software LLC All Rights Reserved - For use by licensed users only.