]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Arithmetic Operations//divides |40 |
2 | ||
3 | divides | |
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 divides | |
19 | { | |
20 | typedef |unspecified| type; | |
21 | }; | |
22 | ||
23 | ||
24 | ||
25 | Description | |
26 | ----------- | |
27 | ||
28 | Returns the quotient of its arguments. | |
29 | ||
30 | ||
31 | Header | |
32 | ------ | |
33 | ||
34 | .. parsed-literal:: | |
35 | ||
36 | #include <boost/mpl/divides.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 divides<c1,\ |...|\ c\ *n*\>::type r; | |
67 | ||
68 | :Return type: | |
69 | |Integral Constant|. | |
70 | ||
71 | :Precondition: | |
72 | ``c2::value != 0``, |...| ``cn::value != 0``. | |
73 | ||
74 | :Semantics: | |
75 | Equivalent to | |
76 | ||
77 | .. parsed-literal:: | |
78 | ||
79 | typedef integral_c< | |
80 | typeof(c1::value / c2::value) | |
81 | , ( c1::value / c2::value ) | |
82 | > c; | |
83 | ||
84 | typedef divides<c,c3,\ |...|\c\ *n*\>::type r; | |
85 | ||
86 | .. .......................................................................... | |
87 | ||
88 | .. parsed-literal:: | |
89 | ||
90 | typedef divides<c1,\ |...|\ c\ *n*\> r; | |
91 | ||
92 | :Return type: | |
93 | |Integral Constant|. | |
94 | ||
95 | :Precondition: | |
96 | ``c2::value != 0``, |...| ``cn::value != 0``. | |
97 | ||
98 | :Semantics: | |
99 | Equivalent to | |
100 | ||
101 | .. parsed-literal:: | |
102 | ||
103 | struct r : divides<c1,\ |...|\ c\ *n*\>::type {}; | |
104 | ||
105 | ||
106 | Complexity | |
107 | ---------- | |
108 | ||
109 | Amortized constant time. | |
110 | ||
111 | ||
112 | Example | |
113 | ------- | |
114 | ||
115 | .. parsed-literal:: | |
116 | ||
117 | typedef divides< int_<-10>, int_<3>, long_<1> >::type r; | |
118 | BOOST_MPL_ASSERT_RELATION( r::value, ==, -3 ); | |
119 | BOOST_MPL_ASSERT(( is_same< r::value_type, long > )); | |
120 | ||
121 | ||
122 | See also | |
123 | -------- | |
124 | ||
125 | |Arithmetic Operations|, |Numeric Metafunction|, |numeric_cast|, |times|, |modulus|, |plus| | |
126 | ||
127 | ||
128 |