static_min_max.hpp 1.6 KB

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