19 #ifndef BOOST_GIL_PROMOTE_INTEGRAL_HPP
20 #define BOOST_GIL_PROMOTE_INTEGRAL_HPP
22 #include <boost/mp11/list.hpp>
26 #include <type_traits>
28 namespace boost {
namespace gil
31 namespace detail {
namespace promote_integral
38 bool IsFundamental = std::is_fundamental<T>::value
44 struct bit_size<T, true> : std::integral_constant<std::size_t, (CHAR_BIT * sizeof(T))> {};
49 typename IntegralTypes,
52 struct promote_to_larger
54 using current_type = boost::mp11::mp_first<IntegralTypes>;
55 using list_after_front = boost::mp11::mp_rest<IntegralTypes>;
57 using type =
typename std::conditional
59 (bit_size<current_type>::value >= MinSize),
61 typename promote_to_larger
72 template <
typename T, std::
size_t MinSize>
73 struct promote_to_larger<T,
boost::mp11::mp_list<>, MinSize>
117 bool PromoteUnsignedToUnsigned =
false,
118 bool UseCheckedInteger =
false,
119 bool IsIntegral = std::is_integral<T>::value
124 static bool const is_unsigned = std::is_unsigned<T>::value;
126 using bit_size_type = detail::promote_integral::bit_size<T>;
135 using min_bit_size_type =
typename std::conditional
137 (PromoteUnsignedToUnsigned && is_unsigned),
138 std::integral_constant<std::size_t, (2 * bit_size_type::value)>,
139 typename std::conditional
142 std::integral_constant<std::size_t, (2 * bit_size_type::value + 1)>,
143 std::integral_constant<std::size_t, (2 * bit_size_type::value - 1)>
149 using signed_integral_types = boost::mp11::mp_list
152 #if defined(BOOST_HAS_LONG_LONG)
153 , boost::long_long_type
159 using unsigned_integral_types = boost::mp11::mp_list
161 unsigned short,
unsigned int,
unsigned long, std::size_t
162 #if defined(BOOST_HAS_LONG_LONG)
163 , boost::ulong_long_type
170 using integral_types =
typename std::conditional
172 (is_unsigned && PromoteUnsignedToUnsigned),
173 unsigned_integral_types,
174 signed_integral_types
178 using type =
typename detail::promote_integral::promote_to_larger
182 min_bit_size_type::value
187 template <
typename T,
bool PromoteUn
signedToUn
signed,
bool UseCheckedInteger>
190 T, PromoteUnsignedToUnsigned, UseCheckedInteger, false
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36