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