1.. Metafunctions/Arithmetic Operations//negate |60
2
3negate
4======
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename T
13        >
14    struct negate
15    {
16        typedef |unspecified| type;
17    };
18
19
20
21Description
22-----------
23
24Returns the negative (additive inverse) of its argument.
25
26
27Header
28------
29
30.. parsed-literal::
31
32    #include <boost/mpl/negate.hpp>
33    #include <boost/mpl/arithmetic.hpp>
34
35
36Model of
37--------
38
39|Numeric Metafunction|
40
41
42Parameters
43----------
44
45+---------------+---------------------------+-----------------------------------------------+
46| Parameter     | Requirement               | Description                                   |
47+===============+===========================+===============================================+
48| ``T``         | |Integral Constant|       | Operation's argument.                         |
49+---------------+---------------------------+-----------------------------------------------+
50
51|Note:| |numeric metafunction note| |-- end note|
52
53
54Expression semantics
55--------------------
56
57For any |Integral Constant| ``c``:
58
59.. parsed-literal::
60
61    typedef negate<c>::type r;
62
63:Return type:
64    |Integral Constant|.
65
66:Semantics:
67    Equivalent to
68
69    .. parsed-literal::
70
71        typedef integral_c< c::value_type, ( -c::value ) > r;
72
73.. ..........................................................................
74
75.. parsed-literal::
76
77    typedef negate<c> r;
78
79:Return type:
80    |Integral Constant|.
81
82:Semantics:
83    Equivalent to
84
85    .. parsed-literal::
86
87        struct r : negate<c>::type {};
88
89
90Complexity
91----------
92
93Amortized constant time.
94
95
96Example
97-------
98
99.. parsed-literal::
100
101    typedef negate< int_<-10> >::type r;
102    BOOST_MPL_ASSERT_RELATION( r::value, ==, 10 );
103    BOOST_MPL_ASSERT(( is_same< r::value_type, int > ));
104
105
106See also
107--------
108
109|Arithmetic Operations|, |Numeric Metafunction|, |numeric_cast|, |plus|, |minus|, |times|
110
111
112.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
113   Distributed under the Boost Software License, Version 1.0. (See accompanying
114   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
115