]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Arithmetic Operations//negate |60 |
2 | ||
3 | negate | |
4 | ====== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename T | |
13 | > | |
14 | struct negate | |
15 | { | |
16 | typedef |unspecified| type; | |
17 | }; | |
18 | ||
19 | ||
20 | ||
21 | Description | |
22 | ----------- | |
23 | ||
24 | Returns the negative (additive inverse) of its argument. | |
25 | ||
26 | ||
27 | Header | |
28 | ------ | |
29 | ||
30 | .. parsed-literal:: | |
31 | ||
32 | #include <boost/mpl/negate.hpp> | |
33 | #include <boost/mpl/arithmetic.hpp> | |
34 | ||
35 | ||
36 | Model of | |
37 | -------- | |
38 | ||
39 | |Numeric Metafunction| | |
40 | ||
41 | ||
42 | Parameters | |
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 | ||
54 | Expression semantics | |
55 | -------------------- | |
56 | ||
57 | For 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 | ||
90 | Complexity | |
91 | ---------- | |
92 | ||
93 | Amortized constant time. | |
94 | ||
95 | ||
96 | Example | |
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 | ||
106 | See also | |
107 | -------- | |
108 | ||
109 | |Arithmetic Operations|, |Numeric Metafunction|, |numeric_cast|, |plus|, |minus|, |times| | |
110 | ||
111 | ||
112 |