largest_int.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef BOOST_MPL_AUX_LARGEST_INT_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_LARGEST_INT_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/if.hpp>
  14. #include <boost/mpl/int.hpp>
  15. #include <boost/mpl/aux_/config/integral.hpp>
  16. #include <boost/config.hpp>
  17. namespace boost { namespace mpl { namespace aux {
  18. template< typename T > struct integral_rank;
  19. template<> struct integral_rank<bool> : int_<1> {};
  20. template<> struct integral_rank<signed char> : int_<2> {};
  21. template<> struct integral_rank<char> : int_<3> {};
  22. template<> struct integral_rank<unsigned char> : int_<4> {};
  23. #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
  24. template<> struct integral_rank<wchar_t> : int_<5> {};
  25. #endif
  26. template<> struct integral_rank<short> : int_<6> {};
  27. template<> struct integral_rank<unsigned short> : int_<7> {};
  28. template<> struct integral_rank<int> : int_<8> {};
  29. template<> struct integral_rank<unsigned int> : int_<9> {};
  30. template<> struct integral_rank<long> : int_<10> {};
  31. template<> struct integral_rank<unsigned long> : int_<11> {};
  32. #if defined(BOOST_HAS_LONG_LONG)
  33. template<> struct integral_rank<long_long_type> : int_<12> {};
  34. template<> struct integral_rank<ulong_long_type>: int_<13> {};
  35. #endif
  36. template< typename T1, typename T2 > struct largest_int
  37. #if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC)
  38. : if_c<
  39. ( integral_rank<T1>::value >= integral_rank<T2>::value )
  40. , T1
  41. , T2
  42. >
  43. {
  44. #else
  45. {
  46. enum { rank1 = integral_rank<T1>::value };
  47. enum { rank2 = integral_rank<T2>::value };
  48. typedef typename if_c< (rank1 >= rank2),T1,T2 >::type type;
  49. #endif
  50. };
  51. }}}
  52. #endif // BOOST_MPL_AUX_LARGEST_INT_HPP_INCLUDED