...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
template< typename T > struct negate { typedef unspecified type; };
Returns the negative (additive inverse) of its argument [1].
#include "boost/mpl/negate.hpp"
Parameter | Requirement | Description |
---|---|---|
T | A model of Integral Constant |
Expression | Expression type | Precondition | Semantics | Postcondition |
---|---|---|---|---|
typedef negate<t>::type n; | A model of Integral Constant | Equivalent to typedef integral_c<t::value_type, -t::value> n; |
Amortized constant time.
typedef negate< integral_c<short,-10> >::type n; BOOST_STATIC_ASSERT(n::value == 10)); BOOST_MPL_ASSERT_IS_SAME(n::value_type, short);
[1] The negate
metafunction can be (and is expected to be) specialized by user to work on user-defined types that do not satisfy the Integral Constant requirements. The requirements listed here are the ones imposed by the default implementation.
Metafunctions, minus
, plus
, multiplies
, divides
, modulus