remove \r
[extl.git] / extl / mpl / math / max_min.h
blob80a26b59bd87ed2c3c029a164e8d146307a7025c
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: max_min.h
4 * Created: 08.05.13
5 * Updated: 08.05.13
7 * Brief: The maximum and minimum value
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_MPL_MATH_MAX_MIN_H
13 #define EXTL_MPL_MATH_MAX_MIN_H
15 /*!\file max_min.h
16 * \brief The maximum and minimum value
19 /* ///////////////////////////////////////////////////////////////////////
20 * Includes
22 #include "math.h"
23 #include "../int_.h"
25 /* ///////////////////////////////////////////////////////////////////////
26 * ::extl::mpl namespace
28 EXTL_MPL_BEGIN_WHOLE_NAMESPACE
30 /// The maximum value
31 template < e_umax_int_t N1, e_umax_int_t N2 >
32 struct max
34 EXTL_STATIC_MEMBER_CONST(e_umax_int_t, value = (N1 > N2)? N1 : N2);
37 /// The maximum value
38 template < e_umax_int_t N1, e_umax_int_t N2 >
39 struct max_2 : max<N1, N2> {};
41 /// The maximum value
42 template < e_umax_int_t N1, e_umax_int_t N2, e_umax_int_t N3 >
43 struct max_3
45 EXTL_STATIC_MEMBER_CONST(e_umax_int_t, value = ((max<N1, N2>::value) > N3)? (max<N1, N2>::value) : N3);
48 /// The maximum value
49 template < e_umax_int_t N1, e_umax_int_t N2, e_umax_int_t N3, e_umax_int_t N4 >
50 struct max_4
52 EXTL_STATIC_MEMBER_CONST(e_umax_int_t, value = ((max<N1, N2>::value) > (max<N3, N4>::value))?
53 (max<N1, N2>::value) : (max<N3, N4>::value));
56 /// The minimum value
57 template < e_umax_int_t N1, e_umax_int_t N2 >
58 struct min
60 EXTL_STATIC_MEMBER_CONST(e_umax_int_t, value = (N1 < N2)? N1 : N2);
63 /// The minimum value
64 template < e_umax_int_t N1, e_umax_int_t N2 >
65 struct min_2 : min<N1, N2> {};
67 /// The minimum value
68 template < e_umax_int_t N1, e_umax_int_t N2, e_umax_int_t N3 >
69 struct min_3
71 EXTL_STATIC_MEMBER_CONST(e_umax_int_t, value = ((min<N1, N2>::value) < N3)? (min<N1, N2>::value) : N3);
74 /// The minimum value
75 template < e_umax_int_t N1, e_umax_int_t N2, e_umax_int_t N3, e_umax_int_t N4 >
76 struct min_4
78 EXTL_STATIC_MEMBER_CONST(e_umax_int_t, value = ((min<N1, N2>::value) < (min<N3, N4>::value))?
79 (min<N1, N2>::value) : (min<N3, N4>::value));
81 /* ///////////////////////////////////////////////////////////////////////
82 * Unit testing
84 #ifdef EXTL_MPL_MATH_MAX_MIN_TEST_ENABLE
85 # include "unit_test/max_min_test.h"
86 #endif
87 /* ///////////////////////////////////////////////////////////////////////
88 * ::extl::mpl namespace
90 EXTL_MPL_END_WHOLE_NAMESPACE
92 /* //////////////////////////////////////////////////////////////////// */
93 #endif /* EXTL_MPL_MATH_MAX_MIN_H */
94 /* //////////////////////////////////////////////////////////////////// */