]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Arithmetic Operations//minus |20 |
2 | ||
3 | minus | |
4 | ===== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename T1 | |
13 | , typename T2 | |
14 | , typename T3 = |unspecified| | |
15 | |...| | |
16 | , typename T\ *n* = |unspecified| | |
17 | > | |
18 | struct minus | |
19 | { | |
20 | typedef |unspecified| type; | |
21 | }; | |
22 | ||
23 | ||
24 | ||
25 | Description | |
26 | ----------- | |
27 | ||
28 | Returns the difference of its arguments. | |
29 | ||
30 | ||
31 | Header | |
32 | ------ | |
33 | ||
34 | .. parsed-literal:: | |
35 | ||
36 | #include <boost/mpl/minus.hpp> | |
37 | #include <boost/mpl/arithmetic.hpp> | |
38 | ||
39 | ||
40 | Model of | |
41 | -------- | |
42 | ||
43 | |Numeric Metafunction| | |
44 | ||
45 | ||
46 | Parameters | |
47 | ---------- | |
48 | ||
49 | +---------------+---------------------------+-----------------------------------------------+ | |
50 | | Parameter | Requirement | Description | | |
51 | +===============+===========================+===============================================+ | |
52 | | |T1...Tn| | |Integral Constant| | Operation's arguments. | | |
53 | +---------------+---------------------------+-----------------------------------------------+ | |
54 | ||
55 | |Note:| |numeric metafunction note| |-- end note| | |
56 | ||
57 | ||
58 | Expression semantics | |
59 | -------------------- | |
60 | ||
61 | For any |Integral Constant|\ s |c1...cn|: | |
62 | ||
63 | ||
64 | .. parsed-literal:: | |
65 | ||
66 | typedef minus<c1,\ |...|\ c\ *n*\>::type r; | |
67 | ||
68 | :Return type: | |
69 | |Integral Constant|. | |
70 | ||
71 | :Semantics: | |
72 | Equivalent to | |
73 | ||
74 | .. parsed-literal:: | |
75 | ||
76 | typedef integral_c< | |
77 | typeof(c1::value - c2::value) | |
78 | , ( c1::value - c2::value ) | |
79 | > c; | |
80 | ||
81 | typedef minus<c,c3,\ |...|\c\ *n*\>::type r; | |
82 | ||
83 | .. .......................................................................... | |
84 | ||
85 | .. parsed-literal:: | |
86 | ||
87 | typedef minus<c1,\ |...|\ c\ *n*\> r; | |
88 | ||
89 | :Return type: | |
90 | |Integral Constant|. | |
91 | ||
92 | :Semantics: | |
93 | Equivalent to | |
94 | ||
95 | .. parsed-literal:: | |
96 | ||
97 | struct r : minus<c1,\ |...|\ c\ *n*\>::type {}; | |
98 | ||
99 | ||
100 | Complexity | |
101 | ---------- | |
102 | ||
103 | Amortized constant time. | |
104 | ||
105 | ||
106 | Example | |
107 | ------- | |
108 | ||
109 | .. parsed-literal:: | |
110 | ||
111 | typedef minus< int_<-10>, int_<3>, long_<1> >::type r; | |
112 | BOOST_MPL_ASSERT_RELATION( r::value, ==, -14 ); | |
113 | BOOST_MPL_ASSERT(( is_same< r::value_type, long > )); | |
114 | ||
115 | ||
116 | See also | |
117 | -------- | |
118 | ||
119 | |Arithmetic Operations|, |Numeric Metafunction|, |numeric_cast|, |plus|, |negate|, |times| | |
120 | ||
121 | ||
122 |