static_min_max.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
  11. namespace boost
  12. {
  13. // Compile-time extrema class declarations ---------------------------------//
  14. // Get the minimum or maximum of two values, signed or unsigned.
  15. template < long Value1, long Value2 >
  16. struct static_signed_min
  17. {
  18. BOOST_STATIC_CONSTANT( long, value = (Value1 > Value2) ? Value2 : Value1 );
  19. };
  20. template < long Value1, long Value2 >
  21. struct static_signed_max
  22. {
  23. BOOST_STATIC_CONSTANT( long, value = (Value1 < Value2) ? Value2 : Value1 );
  24. };
  25. template < unsigned long Value1, unsigned long Value2 >
  26. struct static_unsigned_min
  27. {
  28. BOOST_STATIC_CONSTANT( unsigned long, value
  29. = (Value1 > Value2) ? Value2 : Value1 );
  30. };
  31. template < unsigned long Value1, unsigned long Value2 >
  32. struct static_unsigned_max
  33. {
  34. BOOST_STATIC_CONSTANT( unsigned long, value
  35. = (Value1 < Value2) ? Value2 : Value1 );
  36. };
  37. } // namespace boost
  38. #endif // BOOST_INTEGER_STATIC_MIN_MAX_HPP