Namespaces
Variants
Views
Actions

std::negate

From cppreference.com
< cpp‎ | utility‎ | functional
Revision as of 21:15, 31 May 2013 by P12bot (Talk | contribs)

 
 
 
Function objects


Function wrappers
(C++11)
(C++11)
Bind
(C++11)
Reference wrappers
(C++11)(C++11)
Operator wrappers
Negators
Deprecated binders and adaptors
(deprecated)
(deprecated)
(deprecated)
(deprecated)
(deprecated)(deprecated)(deprecated)(deprecated)
(deprecated)
(deprecated)(deprecated)(deprecated)(deprecated)
(deprecated)(deprecated)
(deprecated)(deprecated)
 
Defined in header <functional>
template< class T >
struct negate;

Function object for performing negation. Effectively calls operator- on an instance of type T.

Contents

Member types

Type Definition
result_type T
argument_type T

Member functions

operator()
returns the negation of the argument
(public member function)

std::negate::operator()

T operator()( const T& arg ) const;

Returns the negation of arg.

Parameters

arg - value to compute negation of

Return value

The result of -arg.

Exceptions

(none)

Possible implementation

T operator()(const T &arg) const 
{
    return -arg;
}