16 #ifndef BOOST_GIL_PROMOTE_INTEGRAL_HPP    17 #define BOOST_GIL_PROMOTE_INTEGRAL_HPP    19 #include <boost/mpl/begin.hpp>    20 #include <boost/mpl/deref.hpp>    21 #include <boost/mpl/end.hpp>    22 #include <boost/mpl/list.hpp>    23 #include <boost/mpl/next.hpp>    27 #include <type_traits>    29 namespace boost { 
namespace gil
    32 namespace detail { 
namespace promote_integral
    39     bool IsFundamental = std::is_fundamental<T>::value
    45 struct bit_size<T, true> : std::integral_constant<std::size_t, (CHAR_BIT * sizeof(T))> {};
    54 struct promote_to_larger
    56     using current_type = 
typename boost::mpl::deref<Iterator>::type;
    58     using type = 
typename std::conditional
    60             (bit_size<current_type>::value >= MinSize),
    62             typename promote_to_larger
    65                     typename boost::mpl::next<Iterator>::type,
    74 template <
typename T, 
typename EndIterator, std::
size_t MinSize>
    75 struct promote_to_larger<T, EndIterator, EndIterator, MinSize>
   119     bool PromoteUnsignedToUnsigned = 
false,
   120     bool UseCheckedInteger = 
false,
   121     bool IsIntegral = std::is_integral<T>::value
   126     static bool const is_unsigned = std::is_unsigned<T>::value;
   128     using bit_size_type = detail::promote_integral::bit_size<T>;
   137     using min_bit_size_type = 
typename std::conditional
   139             (PromoteUnsignedToUnsigned && is_unsigned),
   140             std::integral_constant<std::size_t, (2 * bit_size_type::value)>,
   141             typename std::conditional
   144                     std::integral_constant<std::size_t, (2 * bit_size_type::value + 1)>,
   145                     std::integral_constant<std::size_t, (2 * bit_size_type::value - 1)>
   151     using signed_integral_types = boost::mpl::list
   154 #if defined(BOOST_HAS_LONG_LONG)   155             , boost::long_long_type
   161     using unsigned_integral_types = boost::mpl::list
   163             unsigned short, 
unsigned int, 
unsigned long, std::size_t
   164 #if defined(BOOST_HAS_LONG_LONG)   165             , boost::ulong_long_type
   172     using integral_types = 
typename std::conditional
   174             (is_unsigned && PromoteUnsignedToUnsigned),
   175             unsigned_integral_types,
   176             signed_integral_types
   180     using type = 
typename detail::promote_integral::promote_to_larger
   183             typename boost::mpl::begin<integral_types>::type,
   184             typename boost::mpl::end<integral_types>::type,
   185             min_bit_size_type::value
   190 template <
typename T, 
bool PromoteUn
signedToUn
signed, 
bool UseCheckedInteger>
   193         T, PromoteUnsignedToUnsigned, UseCheckedInteger, false
   202 #endif // BOOST_GIL_PROMOTE_INTEGRAL_HPP