...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Metafunctions / Arithmetic Operations / negate |
Returns the negative (additive inverse) of its argument.
#include <boost/mpl/negate.hpp> #include <boost/mpl/arithmetic.hpp>
Parameter | Requirement | Description |
---|---|---|
T | Integral Constant | Operation's argument. |
[Note: The requirements listed in this specification are the ones imposed by the default implementation. See Numeric Metafunction concept for the details on how to provide an implementation for a user-defined numeric type that does not satisfy the Integral Constant requirements. — end note]
For any Integral Constant c:
typedef negate<c>::type r;
Return type: | Integral Constant. |
---|---|
Semantics: | Equivalent to typedef integral_c< c::value_type, ( -c::value ) > r; |
typedef negate<c> r;
Return type: | Integral Constant. |
---|---|
Semantics: | Equivalent to struct r : negate<c>::type {}; |
Amortized constant time.
typedef negate< int_<-10> >::type r; BOOST_MPL_ASSERT_RELATION( r::value, ==, 10 ); BOOST_MPL_ASSERT(( is_same< r::value_type, int > ));