]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/multiprecision/detail/utype_helper.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / multiprecision / detail / utype_helper.hpp
CommitLineData
7c673cae
FG
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)
6//
7
8#ifndef BOOST_MP_UTYPE_HELPER_HPP
92f5a8d4 9#define BOOST_MP_UTYPE_HELPER_HPP
7c673cae 10
92f5a8d4
TL
11#include <limits>
12#include <boost/cstdint.hpp>
7c673cae 13
92f5a8d4
TL
14namespace boost {
15namespace multiprecision {
16namespace detail {
17template <const unsigned>
18struct utype_helper
19{
20 typedef boost::uint64_t exact;
21};
22template <>
23struct utype_helper<0U>
24{
25 typedef boost::uint8_t exact;
26};
27template <>
28struct utype_helper<1U>
29{
30 typedef boost::uint8_t exact;
31};
32template <>
33struct utype_helper<2U>
34{
35 typedef boost::uint8_t exact;
36};
37template <>
38struct utype_helper<3U>
39{
40 typedef boost::uint8_t exact;
41};
42template <>
43struct utype_helper<4U>
44{
45 typedef boost::uint8_t exact;
46};
47template <>
48struct utype_helper<5U>
49{
50 typedef boost::uint8_t exact;
51};
52template <>
53struct utype_helper<6U>
54{
55 typedef boost::uint8_t exact;
56};
57template <>
58struct utype_helper<7U>
59{
60 typedef boost::uint8_t exact;
61};
62template <>
63struct utype_helper<8U>
64{
65 typedef boost::uint8_t exact;
66};
7c673cae 67
92f5a8d4
TL
68template <>
69struct utype_helper<9U>
70{
71 typedef boost::uint16_t exact;
72};
73template <>
74struct utype_helper<10U>
75{
76 typedef boost::uint16_t exact;
77};
78template <>
79struct utype_helper<11U>
80{
81 typedef boost::uint16_t exact;
82};
83template <>
84struct utype_helper<12U>
85{
86 typedef boost::uint16_t exact;
87};
88template <>
89struct utype_helper<13U>
90{
91 typedef boost::uint16_t exact;
92};
93template <>
94struct utype_helper<14U>
95{
96 typedef boost::uint16_t exact;
97};
98template <>
99struct utype_helper<15U>
100{
101 typedef boost::uint16_t exact;
102};
103template <>
104struct utype_helper<16U>
105{
106 typedef boost::uint16_t exact;
107};
7c673cae 108
92f5a8d4
TL
109template <>
110struct utype_helper<17U>
111{
112 typedef boost::uint32_t exact;
113};
114template <>
115struct utype_helper<18U>
116{
117 typedef boost::uint32_t exact;
118};
119template <>
120struct utype_helper<19U>
121{
122 typedef boost::uint32_t exact;
123};
124template <>
125struct utype_helper<20U>
126{
127 typedef boost::uint32_t exact;
128};
129template <>
130struct utype_helper<21U>
131{
132 typedef boost::uint32_t exact;
133};
134template <>
135struct utype_helper<22U>
136{
137 typedef boost::uint32_t exact;
138};
139template <>
140struct utype_helper<23U>
141{
142 typedef boost::uint32_t exact;
143};
144template <>
145struct utype_helper<24U>
146{
147 typedef boost::uint32_t exact;
148};
149template <>
150struct utype_helper<25U>
151{
152 typedef boost::uint32_t exact;
153};
154template <>
155struct utype_helper<26U>
156{
157 typedef boost::uint32_t exact;
158};
159template <>
160struct utype_helper<27U>
161{
162 typedef boost::uint32_t exact;
163};
164template <>
165struct utype_helper<28U>
166{
167 typedef boost::uint32_t exact;
168};
169template <>
170struct utype_helper<29U>
171{
172 typedef boost::uint32_t exact;
173};
174template <>
175struct utype_helper<30U>
176{
177 typedef boost::uint32_t exact;
178};
179template <>
180struct utype_helper<31U>
181{
182 typedef boost::uint32_t exact;
183};
184template <>
185struct utype_helper<32U>
186{
187 typedef boost::uint32_t exact;
188};
7c673cae 189
92f5a8d4
TL
190template <>
191struct utype_helper<33U>
192{
193 typedef boost::uint64_t exact;
194};
195template <>
196struct utype_helper<34U>
197{
198 typedef boost::uint64_t exact;
199};
200template <>
201struct utype_helper<35U>
202{
203 typedef boost::uint64_t exact;
204};
205template <>
206struct utype_helper<36U>
207{
208 typedef boost::uint64_t exact;
209};
210template <>
211struct utype_helper<37U>
212{
213 typedef boost::uint64_t exact;
214};
215template <>
216struct utype_helper<38U>
217{
218 typedef boost::uint64_t exact;
219};
220template <>
221struct utype_helper<39U>
222{
223 typedef boost::uint64_t exact;
224};
225template <>
226struct utype_helper<40U>
227{
228 typedef boost::uint64_t exact;
229};
230template <>
231struct utype_helper<41U>
232{
233 typedef boost::uint64_t exact;
234};
235template <>
236struct utype_helper<42U>
237{
238 typedef boost::uint64_t exact;
239};
240template <>
241struct utype_helper<43U>
242{
243 typedef boost::uint64_t exact;
244};
245template <>
246struct utype_helper<44U>
247{
248 typedef boost::uint64_t exact;
249};
250template <>
251struct utype_helper<45U>
252{
253 typedef boost::uint64_t exact;
254};
255template <>
256struct utype_helper<46U>
257{
258 typedef boost::uint64_t exact;
259};
260template <>
261struct utype_helper<47U>
262{
263 typedef boost::uint64_t exact;
264};
265template <>
266struct utype_helper<48U>
267{
268 typedef boost::uint64_t exact;
269};
270template <>
271struct utype_helper<49U>
272{
273 typedef boost::uint64_t exact;
274};
275template <>
276struct utype_helper<50U>
277{
278 typedef boost::uint64_t exact;
279};
280template <>
281struct utype_helper<51U>
282{
283 typedef boost::uint64_t exact;
284};
285template <>
286struct utype_helper<52U>
287{
288 typedef boost::uint64_t exact;
289};
290template <>
291struct utype_helper<53U>
292{
293 typedef boost::uint64_t exact;
294};
295template <>
296struct utype_helper<54U>
297{
298 typedef boost::uint64_t exact;
299};
300template <>
301struct utype_helper<55U>
302{
303 typedef boost::uint64_t exact;
304};
305template <>
306struct utype_helper<56U>
307{
308 typedef boost::uint64_t exact;
309};
310template <>
311struct utype_helper<57U>
312{
313 typedef boost::uint64_t exact;
314};
315template <>
316struct utype_helper<58U>
317{
318 typedef boost::uint64_t exact;
319};
320template <>
321struct utype_helper<59U>
322{
323 typedef boost::uint64_t exact;
324};
325template <>
326struct utype_helper<60U>
327{
328 typedef boost::uint64_t exact;
329};
330template <>
331struct utype_helper<61U>
332{
333 typedef boost::uint64_t exact;
334};
335template <>
336struct utype_helper<62U>
337{
338 typedef boost::uint64_t exact;
339};
340template <>
341struct utype_helper<63U>
342{
343 typedef boost::uint64_t exact;
344};
345template <>
346struct utype_helper<64U>
347{
348 typedef boost::uint64_t exact;
349};
7c673cae 350
92f5a8d4
TL
351template <class unsigned_type>
352int utype_prior(unsigned_type ui)
353{
354 // TBD: Implement a templated binary search for this.
355 int priority_bit;
7c673cae 356
92f5a8d4 357 unsigned_type priority_mask = unsigned_type(unsigned_type(1U) << (std::numeric_limits<unsigned_type>::digits - 1));
7c673cae 358
92f5a8d4
TL
359 for (priority_bit = std::numeric_limits<unsigned_type>::digits - 1; priority_bit >= 0; --priority_bit)
360 {
361 if (unsigned_type(priority_mask & ui) != unsigned_type(0U))
7c673cae 362 {
92f5a8d4 363 break;
7c673cae
FG
364 }
365
366 priority_mask >>= 1;
92f5a8d4 367 }
7c673cae 368
92f5a8d4
TL
369 return priority_bit;
370}
7c673cae 371
92f5a8d4 372}}} // namespace boost::multiprecision::detail
7c673cae
FG
373
374#endif // BOOST_MP_UTYPE_HELPER_HPP