File indexing completed on 2025-01-18 09:42:24
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MP_UTYPE_HELPER_HPP
0009 #define BOOST_MP_UTYPE_HELPER_HPP
0010
0011 #include <limits>
0012 #include <cstdint>
0013
0014 namespace boost {
0015 namespace multiprecision {
0016 namespace detail {
0017 template <const unsigned>
0018 struct utype_helper
0019 {
0020 using exact = std::uint64_t;
0021 };
0022 template <>
0023 struct utype_helper<0U>
0024 {
0025 using exact = boost::uint8_t;
0026 };
0027 template <>
0028 struct utype_helper<1U>
0029 {
0030 using exact = boost::uint8_t;
0031 };
0032 template <>
0033 struct utype_helper<2U>
0034 {
0035 using exact = boost::uint8_t;
0036 };
0037 template <>
0038 struct utype_helper<3U>
0039 {
0040 using exact = boost::uint8_t;
0041 };
0042 template <>
0043 struct utype_helper<4U>
0044 {
0045 using exact = boost::uint8_t;
0046 };
0047 template <>
0048 struct utype_helper<5U>
0049 {
0050 using exact = boost::uint8_t;
0051 };
0052 template <>
0053 struct utype_helper<6U>
0054 {
0055 using exact = boost::uint8_t;
0056 };
0057 template <>
0058 struct utype_helper<7U>
0059 {
0060 using exact = boost::uint8_t;
0061 };
0062 template <>
0063 struct utype_helper<8U>
0064 {
0065 using exact = boost::uint8_t;
0066 };
0067
0068 template <>
0069 struct utype_helper<9U>
0070 {
0071 using exact = std::uint16_t;
0072 };
0073 template <>
0074 struct utype_helper<10U>
0075 {
0076 using exact = std::uint16_t;
0077 };
0078 template <>
0079 struct utype_helper<11U>
0080 {
0081 using exact = std::uint16_t;
0082 };
0083 template <>
0084 struct utype_helper<12U>
0085 {
0086 using exact = std::uint16_t;
0087 };
0088 template <>
0089 struct utype_helper<13U>
0090 {
0091 using exact = std::uint16_t;
0092 };
0093 template <>
0094 struct utype_helper<14U>
0095 {
0096 using exact = std::uint16_t;
0097 };
0098 template <>
0099 struct utype_helper<15U>
0100 {
0101 using exact = std::uint16_t;
0102 };
0103 template <>
0104 struct utype_helper<16U>
0105 {
0106 using exact = std::uint16_t;
0107 };
0108
0109 template <>
0110 struct utype_helper<17U>
0111 {
0112 using exact = std::uint32_t;
0113 };
0114 template <>
0115 struct utype_helper<18U>
0116 {
0117 using exact = std::uint32_t;
0118 };
0119 template <>
0120 struct utype_helper<19U>
0121 {
0122 using exact = std::uint32_t;
0123 };
0124 template <>
0125 struct utype_helper<20U>
0126 {
0127 using exact = std::uint32_t;
0128 };
0129 template <>
0130 struct utype_helper<21U>
0131 {
0132 using exact = std::uint32_t;
0133 };
0134 template <>
0135 struct utype_helper<22U>
0136 {
0137 using exact = std::uint32_t;
0138 };
0139 template <>
0140 struct utype_helper<23U>
0141 {
0142 using exact = std::uint32_t;
0143 };
0144 template <>
0145 struct utype_helper<24U>
0146 {
0147 using exact = std::uint32_t;
0148 };
0149 template <>
0150 struct utype_helper<25U>
0151 {
0152 using exact = std::uint32_t;
0153 };
0154 template <>
0155 struct utype_helper<26U>
0156 {
0157 using exact = std::uint32_t;
0158 };
0159 template <>
0160 struct utype_helper<27U>
0161 {
0162 using exact = std::uint32_t;
0163 };
0164 template <>
0165 struct utype_helper<28U>
0166 {
0167 using exact = std::uint32_t;
0168 };
0169 template <>
0170 struct utype_helper<29U>
0171 {
0172 using exact = std::uint32_t;
0173 };
0174 template <>
0175 struct utype_helper<30U>
0176 {
0177 using exact = std::uint32_t;
0178 };
0179 template <>
0180 struct utype_helper<31U>
0181 {
0182 using exact = std::uint32_t;
0183 };
0184 template <>
0185 struct utype_helper<32U>
0186 {
0187 using exact = std::uint32_t;
0188 };
0189
0190 template <>
0191 struct utype_helper<33U>
0192 {
0193 using exact = std::uint64_t;
0194 };
0195 template <>
0196 struct utype_helper<34U>
0197 {
0198 using exact = std::uint64_t;
0199 };
0200 template <>
0201 struct utype_helper<35U>
0202 {
0203 using exact = std::uint64_t;
0204 };
0205 template <>
0206 struct utype_helper<36U>
0207 {
0208 using exact = std::uint64_t;
0209 };
0210 template <>
0211 struct utype_helper<37U>
0212 {
0213 using exact = std::uint64_t;
0214 };
0215 template <>
0216 struct utype_helper<38U>
0217 {
0218 using exact = std::uint64_t;
0219 };
0220 template <>
0221 struct utype_helper<39U>
0222 {
0223 using exact = std::uint64_t;
0224 };
0225 template <>
0226 struct utype_helper<40U>
0227 {
0228 using exact = std::uint64_t;
0229 };
0230 template <>
0231 struct utype_helper<41U>
0232 {
0233 using exact = std::uint64_t;
0234 };
0235 template <>
0236 struct utype_helper<42U>
0237 {
0238 using exact = std::uint64_t;
0239 };
0240 template <>
0241 struct utype_helper<43U>
0242 {
0243 using exact = std::uint64_t;
0244 };
0245 template <>
0246 struct utype_helper<44U>
0247 {
0248 using exact = std::uint64_t;
0249 };
0250 template <>
0251 struct utype_helper<45U>
0252 {
0253 using exact = std::uint64_t;
0254 };
0255 template <>
0256 struct utype_helper<46U>
0257 {
0258 using exact = std::uint64_t;
0259 };
0260 template <>
0261 struct utype_helper<47U>
0262 {
0263 using exact = std::uint64_t;
0264 };
0265 template <>
0266 struct utype_helper<48U>
0267 {
0268 using exact = std::uint64_t;
0269 };
0270 template <>
0271 struct utype_helper<49U>
0272 {
0273 using exact = std::uint64_t;
0274 };
0275 template <>
0276 struct utype_helper<50U>
0277 {
0278 using exact = std::uint64_t;
0279 };
0280 template <>
0281 struct utype_helper<51U>
0282 {
0283 using exact = std::uint64_t;
0284 };
0285 template <>
0286 struct utype_helper<52U>
0287 {
0288 using exact = std::uint64_t;
0289 };
0290 template <>
0291 struct utype_helper<53U>
0292 {
0293 using exact = std::uint64_t;
0294 };
0295 template <>
0296 struct utype_helper<54U>
0297 {
0298 using exact = std::uint64_t;
0299 };
0300 template <>
0301 struct utype_helper<55U>
0302 {
0303 using exact = std::uint64_t;
0304 };
0305 template <>
0306 struct utype_helper<56U>
0307 {
0308 using exact = std::uint64_t;
0309 };
0310 template <>
0311 struct utype_helper<57U>
0312 {
0313 using exact = std::uint64_t;
0314 };
0315 template <>
0316 struct utype_helper<58U>
0317 {
0318 using exact = std::uint64_t;
0319 };
0320 template <>
0321 struct utype_helper<59U>
0322 {
0323 using exact = std::uint64_t;
0324 };
0325 template <>
0326 struct utype_helper<60U>
0327 {
0328 using exact = std::uint64_t;
0329 };
0330 template <>
0331 struct utype_helper<61U>
0332 {
0333 using exact = std::uint64_t;
0334 };
0335 template <>
0336 struct utype_helper<62U>
0337 {
0338 using exact = std::uint64_t;
0339 };
0340 template <>
0341 struct utype_helper<63U>
0342 {
0343 using exact = std::uint64_t;
0344 };
0345 template <>
0346 struct utype_helper<64U>
0347 {
0348 using exact = std::uint64_t;
0349 };
0350
0351 template <class unsigned_type>
0352 int utype_prior(unsigned_type ui)
0353 {
0354
0355 int priority_bit;
0356
0357 unsigned_type priority_mask = unsigned_type(unsigned_type(1U) << (std::numeric_limits<unsigned_type>::digits - 1));
0358
0359 for (priority_bit = std::numeric_limits<unsigned_type>::digits - 1; priority_bit >= 0; --priority_bit)
0360 {
0361 if (unsigned_type(priority_mask & ui) != unsigned_type(0U))
0362 {
0363 break;
0364 }
0365
0366 priority_mask >>= 1;
0367 }
0368
0369 return priority_bit;
0370 }
0371
0372 }}}
0373
0374 #endif