]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Miscellaneous//min |80 |
2 | ||
3 | min | |
4 | === | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename N1 | |
13 | , typename N2 | |
14 | > | |
15 | struct min | |
16 | { | |
17 | typedef |unspecified| type; | |
18 | }; | |
19 | ||
20 | ||
21 | ||
22 | Description | |
23 | ----------- | |
24 | ||
25 | Returns the smaller of its two arguments. | |
26 | ||
27 | ||
28 | Header | |
29 | ------ | |
30 | ||
31 | .. parsed-literal:: | |
32 | ||
33 | #include <boost/mpl/min_max.hpp> | |
34 | ||
35 | ||
36 | Model of | |
37 | -------- | |
38 | ||
39 | |Metafunction| | |
40 | ||
41 | ||
42 | Parameters | |
43 | ---------- | |
44 | ||
45 | +---------------+-------------------+-------------------------------------------+ | |
46 | | Parameter | Requirement | Description | | |
47 | +===============+===================+===========================================+ | |
48 | | ``N1``, ``N2``| Any type | Types to compare. | | |
49 | +---------------+-------------------+-------------------------------------------+ | |
50 | ||
51 | ||
52 | Expression semantics | |
53 | -------------------- | |
54 | ||
55 | For arbitrary types ``x`` and ``y``: | |
56 | ||
57 | ||
58 | .. parsed-literal:: | |
59 | ||
60 | typedef min<x,y>::type r; | |
61 | ||
62 | ||
63 | :Return type: | |
64 | A type. | |
65 | ||
66 | :Precondition: | |
67 | ``less<x,y>::value`` is a well-formed integral constant expression. | |
68 | ||
69 | :Semantics: | |
70 | Equivalent to | |
71 | ||
72 | .. parsed-literal:: | |
73 | ||
74 | typedef if_< less<x,y>,x,y >::type r; | |
75 | ||
76 | ||
77 | ||
78 | Complexity | |
79 | ---------- | |
80 | ||
81 | Constant time. | |
82 | ||
83 | ||
84 | Example | |
85 | ------- | |
86 | ||
87 | .. parsed-literal:: | |
88 | ||
89 | typedef fold< | |
90 | vector_c<int,1,7,0,-2,5,-1> | |
91 | , int_<-10> | |
92 | , min<_1,_2> | |
93 | >::type r; | |
94 | ||
95 | BOOST_MPL_ASSERT(( is_same< r, int_<-10> > )); | |
96 | ||
97 | ||
98 | See also | |
99 | -------- | |
100 | ||
101 | |Metafunctions|, |Comparison|, |max|, |less|, |min_element| | |
102 | ||
103 | ||
104 |