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