Chris@16
|
1 // Boost integer/static_min_max.hpp header file ----------------------------//
|
Chris@16
|
2
|
Chris@16
|
3 // (C) Copyright Daryle Walker 2001.
|
Chris@16
|
4 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
5 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7
|
Chris@16
|
8 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@16
|
9
|
Chris@16
|
10 #ifndef BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
Chris@16
|
11 #define BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
Chris@16
|
12
|
Chris@16
|
13 #include <boost/integer_fwd.hpp> // self include
|
Chris@16
|
14
|
Chris@16
|
15 namespace boost
|
Chris@16
|
16 {
|
Chris@16
|
17
|
Chris@16
|
18 // Compile-time extrema class declarations ---------------------------------//
|
Chris@16
|
19 // Get the minimum or maximum of two values, signed or unsigned.
|
Chris@16
|
20
|
Chris@16
|
21 template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
|
Chris@16
|
22 struct static_signed_min
|
Chris@16
|
23 {
|
Chris@16
|
24 BOOST_STATIC_CONSTANT(static_min_max_signed_type, value = (Value1 > Value2) ? Value2 : Value1 );
|
Chris@16
|
25 };
|
Chris@16
|
26
|
Chris@16
|
27 template <static_min_max_signed_type Value1, static_min_max_signed_type Value2>
|
Chris@16
|
28 struct static_signed_max
|
Chris@16
|
29 {
|
Chris@16
|
30 BOOST_STATIC_CONSTANT(static_min_max_signed_type, value = (Value1 < Value2) ? Value2 : Value1 );
|
Chris@16
|
31 };
|
Chris@16
|
32
|
Chris@16
|
33 template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
|
Chris@16
|
34 struct static_unsigned_min
|
Chris@16
|
35 {
|
Chris@16
|
36 BOOST_STATIC_CONSTANT(static_min_max_unsigned_type, value
|
Chris@16
|
37 = (Value1 > Value2) ? Value2 : Value1 );
|
Chris@16
|
38 };
|
Chris@16
|
39
|
Chris@16
|
40 template <static_min_max_unsigned_type Value1, static_min_max_unsigned_type Value2>
|
Chris@16
|
41 struct static_unsigned_max
|
Chris@16
|
42 {
|
Chris@16
|
43 BOOST_STATIC_CONSTANT(static_min_max_unsigned_type, value
|
Chris@16
|
44 = (Value1 < Value2) ? Value2 : Value1 );
|
Chris@16
|
45 };
|
Chris@16
|
46
|
Chris@16
|
47
|
Chris@16
|
48 } // namespace boost
|
Chris@16
|
49
|
Chris@16
|
50
|
Chris@16
|
51 #endif // BOOST_INTEGER_STATIC_MIN_MAX_HPP
|