Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is an old version of boost. Click here for the latest version's documentation home page.

[Home]negate

Synopsis

template<
      typename T
    >
struct negate
{
    typedef unspecified type;
};

Description

Returns the negative (additive inverse) of its argument [1].

Definition

#include "boost/mpl/negate.hpp"

Parameters

 Parameter  Requirement  Description  
TA model of Integral Constant

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef negate<t>::type n;A model of Integral ConstantEquivalent to typedef integral_c<t::value_type, -t::value> n;

Complexity

Amortized constant time.

Example

typedef negate< integral_c<short,-10> >::type n;
BOOST_STATIC_ASSERT(n::value == 10));
BOOST_MPL_ASSERT_IS_SAME(n::value_type, short);

Notes

[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.

See also

Metafunctions, minus, plus, multiplies, divides, modulus


Table of Contents
Last edited March 10, 2003 6:33 am