1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright 2012 John Maddock.
3 // Copyright Christopher Kormanyos 2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_MP_UTYPE_HELPER_HPP
9 #define BOOST_MP_UTYPE_HELPER_HPP
15 namespace multiprecision {
17 template <const unsigned>
20 using exact = std::uint64_t;
23 struct utype_helper<0U>
25 using exact = boost::uint8_t;
28 struct utype_helper<1U>
30 using exact = boost::uint8_t;
33 struct utype_helper<2U>
35 using exact = boost::uint8_t;
38 struct utype_helper<3U>
40 using exact = boost::uint8_t;
43 struct utype_helper<4U>
45 using exact = boost::uint8_t;
48 struct utype_helper<5U>
50 using exact = boost::uint8_t;
53 struct utype_helper<6U>
55 using exact = boost::uint8_t;
58 struct utype_helper<7U>
60 using exact = boost::uint8_t;
63 struct utype_helper<8U>
65 using exact = boost::uint8_t;
69 struct utype_helper<9U>
71 using exact = std::uint16_t;
74 struct utype_helper<10U>
76 using exact = std::uint16_t;
79 struct utype_helper<11U>
81 using exact = std::uint16_t;
84 struct utype_helper<12U>
86 using exact = std::uint16_t;
89 struct utype_helper<13U>
91 using exact = std::uint16_t;
94 struct utype_helper<14U>
96 using exact = std::uint16_t;
99 struct utype_helper<15U>
101 using exact = std::uint16_t;
104 struct utype_helper<16U>
106 using exact = std::uint16_t;
110 struct utype_helper<17U>
112 using exact = std::uint32_t;
115 struct utype_helper<18U>
117 using exact = std::uint32_t;
120 struct utype_helper<19U>
122 using exact = std::uint32_t;
125 struct utype_helper<20U>
127 using exact = std::uint32_t;
130 struct utype_helper<21U>
132 using exact = std::uint32_t;
135 struct utype_helper<22U>
137 using exact = std::uint32_t;
140 struct utype_helper<23U>
142 using exact = std::uint32_t;
145 struct utype_helper<24U>
147 using exact = std::uint32_t;
150 struct utype_helper<25U>
152 using exact = std::uint32_t;
155 struct utype_helper<26U>
157 using exact = std::uint32_t;
160 struct utype_helper<27U>
162 using exact = std::uint32_t;
165 struct utype_helper<28U>
167 using exact = std::uint32_t;
170 struct utype_helper<29U>
172 using exact = std::uint32_t;
175 struct utype_helper<30U>
177 using exact = std::uint32_t;
180 struct utype_helper<31U>
182 using exact = std::uint32_t;
185 struct utype_helper<32U>
187 using exact = std::uint32_t;
191 struct utype_helper<33U>
193 using exact = std::uint64_t;
196 struct utype_helper<34U>
198 using exact = std::uint64_t;
201 struct utype_helper<35U>
203 using exact = std::uint64_t;
206 struct utype_helper<36U>
208 using exact = std::uint64_t;
211 struct utype_helper<37U>
213 using exact = std::uint64_t;
216 struct utype_helper<38U>
218 using exact = std::uint64_t;
221 struct utype_helper<39U>
223 using exact = std::uint64_t;
226 struct utype_helper<40U>
228 using exact = std::uint64_t;
231 struct utype_helper<41U>
233 using exact = std::uint64_t;
236 struct utype_helper<42U>
238 using exact = std::uint64_t;
241 struct utype_helper<43U>
243 using exact = std::uint64_t;
246 struct utype_helper<44U>
248 using exact = std::uint64_t;
251 struct utype_helper<45U>
253 using exact = std::uint64_t;
256 struct utype_helper<46U>
258 using exact = std::uint64_t;
261 struct utype_helper<47U>
263 using exact = std::uint64_t;
266 struct utype_helper<48U>
268 using exact = std::uint64_t;
271 struct utype_helper<49U>
273 using exact = std::uint64_t;
276 struct utype_helper<50U>
278 using exact = std::uint64_t;
281 struct utype_helper<51U>
283 using exact = std::uint64_t;
286 struct utype_helper<52U>
288 using exact = std::uint64_t;
291 struct utype_helper<53U>
293 using exact = std::uint64_t;
296 struct utype_helper<54U>
298 using exact = std::uint64_t;
301 struct utype_helper<55U>
303 using exact = std::uint64_t;
306 struct utype_helper<56U>
308 using exact = std::uint64_t;
311 struct utype_helper<57U>
313 using exact = std::uint64_t;
316 struct utype_helper<58U>
318 using exact = std::uint64_t;
321 struct utype_helper<59U>
323 using exact = std::uint64_t;
326 struct utype_helper<60U>
328 using exact = std::uint64_t;
331 struct utype_helper<61U>
333 using exact = std::uint64_t;
336 struct utype_helper<62U>
338 using exact = std::uint64_t;
341 struct utype_helper<63U>
343 using exact = std::uint64_t;
346 struct utype_helper<64U>
348 using exact = std::uint64_t;
351 template <class unsigned_type>
352 int utype_prior(unsigned_type ui)
354 // TBD: Implement a templated binary search for this.
357 unsigned_type priority_mask = unsigned_type(unsigned_type(1U) << (std::numeric_limits<unsigned_type>::digits - 1));
359 for (priority_bit = std::numeric_limits<unsigned_type>::digits - 1; priority_bit >= 0; --priority_bit)
361 if (unsigned_type(priority_mask & ui) != unsigned_type(0U))
372 }}} // namespace boost::multiprecision::detail
374 #endif // BOOST_MP_UTYPE_HELPER_HPP