libstdc++
max_size_type.h
Go to the documentation of this file.
1// <max_size_type.h> -*- C++ -*-
2
3// Copyright (C) 2019-2025 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file bits/max_size_type.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly. @headername{iterator}
28 */
29
30#ifndef _GLIBCXX_MAX_SIZE_TYPE_H
31#define _GLIBCXX_MAX_SIZE_TYPE_H 1
32
33#ifdef _GLIBCXX_SYSHDR
34#pragma GCC system_header
35#endif
36
37#if __cplusplus > 201703L && __cpp_lib_concepts
38#include <ext/numeric_traits.h>
39#include <bit> // __bit_width
40#include <numbers>
41#include <limits> // __glibcxx_integral_traps
42
43// This header implements unsigned and signed integer-class types (as per
44// [iterator.concept.winc]) that are one bit wider than the widest supported
45// integer type.
46//
47// The set of integer types we consider includes the extended integer types
48// __int128 and unsigned __int128 (when they exist).
49
50namespace std _GLIBCXX_VISIBILITY(default)
51{
52_GLIBCXX_BEGIN_NAMESPACE_VERSION
53
54template<typename _Tp>
55 struct numeric_limits;
56
57namespace ranges
58{
59 namespace __detail
60 {
61 class __max_size_type
62 {
63 public:
64 __max_size_type() = default;
65
66 template<typename _Tp> requires integral<_Tp>
67 constexpr
68 __max_size_type(_Tp __i) noexcept
69 : _M_val(__i), _M_msb(__i < 0)
70 { }
71
72 constexpr explicit
73 __max_size_type(const __max_diff_type& __d) noexcept;
74
75 template<typename _Tp> requires integral<_Tp>
76 constexpr explicit
77 operator _Tp() const noexcept
78 { return _M_val; }
79
80 constexpr explicit
81 operator bool() const noexcept
82 { return _M_val != 0 || _M_msb != 0; }
83
84 constexpr __max_size_type
85 operator+() const noexcept
86 { return *this; }
87
88 constexpr __max_size_type
89 operator~() const noexcept
90 { return __max_size_type{~_M_val, !_M_msb}; }
91
92 constexpr __max_size_type
93 operator-() const noexcept
94 { return operator~() + 1; }
95
96 constexpr __max_size_type&
97 operator++() noexcept
98 { return *this += 1; }
99
100 constexpr __max_size_type
101 operator++(int) noexcept
102 {
103 auto __tmp = *this;
104 ++*this;
105 return __tmp;
106 }
107
108 constexpr __max_size_type&
109 operator--() noexcept
110 { return *this -= 1; }
111
112 constexpr __max_size_type
113 operator--(int) noexcept
114 {
115 auto __tmp = *this;
116 --*this;
117 return __tmp;
118 }
119
120 constexpr __max_size_type&
121 operator+=(const __max_size_type& __r) noexcept
122 {
123 const auto __sum = _M_val + __r._M_val;
124 const bool __overflow = (__sum < _M_val);
125 _M_msb = _M_msb ^ __r._M_msb ^ __overflow;
126 _M_val = __sum;
127 return *this;
128 }
129
130 constexpr __max_size_type&
131 operator-=(const __max_size_type& __r) noexcept
132 { return *this += -__r; }
133
134 constexpr __max_size_type&
135 operator*=(__max_size_type __r) noexcept
136 {
137 constexpr __max_size_type __threshold
138 = __rep(1) << (_S_rep_bits / 2 - 1);
139 if (_M_val < __threshold && __r < __threshold)
140 // When both operands are below this threshold then the
141 // multiplication can be safely computed in the base precision.
142 _M_val = _M_val * __r._M_val;
143 else
144 {
145 // Otherwise, perform the multiplication in four steps, by
146 // decomposing the LHS and the RHS into 2*x+a and 2*y+b,
147 // respectively, and computing 4*x*y + 2*x*b + 2*y*a + a*b.
148 const bool __lsb = _M_val & 1;
149 const bool __rlsb = __r._M_val & 1;
150 *this >>= 1;
151 __r >>= 1;
152 _M_val = (2 * _M_val * __r._M_val
153 + _M_val * __rlsb + __r._M_val * __lsb);
154 *this <<= 1;
155 *this += __rlsb * __lsb;
156 }
157
158 return *this;
159 }
160
161 constexpr __max_size_type&
162 operator/=(const __max_size_type& __r) noexcept
163 {
164 __glibcxx_assert(__r != 0);
165
166 if (!_M_msb && !__r._M_msb) [[likely]]
167 _M_val /= __r._M_val;
168 else if (_M_msb && __r._M_msb)
169 {
170 _M_val = (_M_val >= __r._M_val);
171 _M_msb = 0;
172 }
173 else if (!_M_msb && __r._M_msb)
174 _M_val = 0;
175 else if (_M_msb && !__r._M_msb)
176 {
177 // The non-trivial case: the dividend has its MSB set and the
178 // divisor doesn't. In this case we compute ((LHS/2)/RHS)*2
179 // in the base precision. This quantity is either the true
180 // quotient or one less than the true quotient.
181 const auto __orig = *this;
182 *this >>= 1;
183 _M_val /= __r._M_val;
184 *this <<= 1;
185 if (__orig - *this * __r >= __r)
186 ++_M_val;
187 }
188 return *this;
189 }
190
191 constexpr __max_size_type&
192 operator%=(const __max_size_type& __r) noexcept
193 {
194 if (!_M_msb && !__r._M_msb) [[likely]]
195 _M_val %= __r._M_val;
196 else
197 *this -= (*this / __r) * __r;
198 return *this;
199 }
200
201 constexpr __max_size_type&
202 operator<<=(const __max_size_type& __r) noexcept
203 {
204 __glibcxx_assert(__r <= _S_rep_bits);
205 if (__r != 0)
206 {
207 _M_msb = (_M_val >> (_S_rep_bits - __r._M_val)) & 1;
208
209 if (__r._M_val == _S_rep_bits) [[unlikely]]
210 _M_val = 0;
211 else
212 _M_val <<= __r._M_val;
213 }
214 return *this;
215 }
216
217 constexpr __max_size_type&
218 operator>>=(const __max_size_type& __r) noexcept
219 {
220 __glibcxx_assert(__r <= _S_rep_bits);
221 if (__r != 0)
222 {
223 if (__r._M_val == _S_rep_bits) [[unlikely]]
224 _M_val = 0;
225 else
226 _M_val >>= __r._M_val;
227
228 if (_M_msb) [[unlikely]]
229 {
230 _M_val |= __rep(1) << (_S_rep_bits - __r._M_val);
231 _M_msb = 0;
232 }
233 }
234 return *this;
235 }
236
237 constexpr __max_size_type&
238 operator&=(const __max_size_type& __r) noexcept
239 {
240 _M_val &= __r._M_val;
241 _M_msb &= __r._M_msb;
242 return *this;
243 }
244
245 constexpr __max_size_type&
246 operator|=(const __max_size_type& __r) noexcept
247 {
248 _M_val |= __r._M_val;
249 _M_msb |= __r._M_msb;
250 return *this;
251 }
252
253 constexpr __max_size_type&
254 operator^=(const __max_size_type& __r) noexcept
255 {
256 _M_val ^= __r._M_val;
257 _M_msb ^= __r._M_msb;
258 return *this;
259 }
260
261 template<typename _Tp> requires integral<_Tp>
262 friend constexpr _Tp&
263 operator+=(_Tp& __a, const __max_size_type& __b) noexcept
264 { return (__a = static_cast<_Tp>(__a + __b)); }
265
266 template<typename _Tp> requires integral<_Tp>
267 friend constexpr _Tp&
268 operator-=(_Tp& __a, const __max_size_type& __b) noexcept
269 { return (__a = static_cast<_Tp>(__a - __b)); }
270
271 template<typename _Tp> requires integral<_Tp>
272 friend constexpr _Tp&
273 operator*=(_Tp& __a, const __max_size_type& __b) noexcept
274 { return (__a = static_cast<_Tp>(__a * __b)); }
275
276 template<typename _Tp> requires integral<_Tp>
277 friend constexpr _Tp&
278 operator/=(_Tp& __a, const __max_size_type& __b) noexcept
279 { return (__a = static_cast<_Tp>(__a / __b)); }
280
281 template<typename _Tp> requires integral<_Tp>
282 friend constexpr _Tp&
283 operator%=(_Tp& __a, const __max_size_type& __b) noexcept
284 { return (__a = static_cast<_Tp>(__a % __b)); }
285
286 template<typename _Tp> requires integral<_Tp>
287 friend constexpr _Tp&
288 operator&=(_Tp& __a, const __max_size_type& __b) noexcept
289 { return (__a = static_cast<_Tp>(__a & __b)); }
290
291 template<typename _Tp> requires integral<_Tp>
292 friend constexpr _Tp&
293 operator|=(_Tp& __a, const __max_size_type& __b) noexcept
294 { return (__a = static_cast<_Tp>(__a | __b)); }
295
296 template<typename _Tp> requires integral<_Tp>
297 friend constexpr _Tp&
298 operator^=(_Tp& __a, const __max_size_type& __b) noexcept
299 { return (__a = static_cast<_Tp>(__a ^ __b)); }
300
301 template<typename _Tp> requires integral<_Tp>
302 friend constexpr _Tp&
303 operator<<=(_Tp& __a, const __max_size_type& __b) noexcept
304 { return (__a = static_cast<_Tp>(__a << __b)); }
305
306 template<typename _Tp> requires integral<_Tp>
307 friend constexpr _Tp&
308 operator>>=(_Tp& __a, const __max_size_type& __b) noexcept
309 { return (__a = static_cast<_Tp>(__a >> __b)); }
310
311 friend constexpr __max_size_type
312 operator+(__max_size_type __l, const __max_size_type& __r) noexcept
313 {
314 __l += __r;
315 return __l;
316 }
317
318 friend constexpr __max_size_type
319 operator-(__max_size_type __l, const __max_size_type& __r) noexcept
320 {
321 __l -= __r;
322 return __l;
323 }
324
325 friend constexpr __max_size_type
326 operator*(__max_size_type __l, const __max_size_type& __r) noexcept
327 {
328 __l *= __r;
329 return __l;
330 }
331
332 friend constexpr __max_size_type
333 operator/(__max_size_type __l, const __max_size_type& __r) noexcept
334 {
335 __l /= __r;
336 return __l;
337 }
338
339 friend constexpr __max_size_type
340 operator%(__max_size_type __l, const __max_size_type& __r) noexcept
341 {
342 __l %= __r;
343 return __l;
344 }
345
346 friend constexpr __max_size_type
347 operator<<(__max_size_type __l, const __max_size_type& __r) noexcept
348 {
349 __l <<= __r;
350 return __l;
351 }
352
353 friend constexpr __max_size_type
354 operator>>(__max_size_type __l, const __max_size_type& __r) noexcept
355 {
356 __l >>= __r;
357 return __l;
358 }
359
360 friend constexpr __max_size_type
361 operator&(__max_size_type __l, const __max_size_type& __r) noexcept
362 {
363 __l &= __r;
364 return __l;
365 }
366
367 friend constexpr __max_size_type
368 operator|(__max_size_type __l, const __max_size_type& __r) noexcept
369 {
370 __l |= __r;
371 return __l;
372 }
373
374 friend constexpr __max_size_type
375 operator^(__max_size_type __l, const __max_size_type& __r) noexcept
376 {
377 __l ^= __r;
378 return __l;
379 }
380
381 friend constexpr bool
382 operator==(const __max_size_type& __l, const __max_size_type& __r) noexcept
383 { return __l._M_val == __r._M_val && __l._M_msb == __r._M_msb; }
384
385#if __cpp_lib_three_way_comparison
386 friend constexpr strong_ordering
387 operator<=>(const __max_size_type& __l, const __max_size_type& __r) noexcept
388 {
389 if (__l._M_msb ^ __r._M_msb)
390 return __l._M_msb ? strong_ordering::greater : strong_ordering::less;
391 else
392 return __l._M_val <=> __r._M_val;
393 }
394#else
395 friend constexpr bool
396 operator!=(const __max_size_type& __l, const __max_size_type& __r) noexcept
397 { return !(__l == __r); }
398
399 friend constexpr bool
400 operator<(const __max_size_type& __l, const __max_size_type& __r) noexcept
401 {
402 if (__l._M_msb == __r._M_msb)
403 return __l._M_val < __r._M_val;
404 else
405 return __r._M_msb;
406 }
407
408 friend constexpr bool
409 operator>(const __max_size_type& __l, const __max_size_type& __r) noexcept
410 { return __r < __l; }
411
412 friend constexpr bool
413 operator<=(const __max_size_type& __l, const __max_size_type& __r) noexcept
414 { return !(__l > __r); }
415
416 friend constexpr bool
417 operator>=(const __max_size_type& __l, const __max_size_type& __r) noexcept
418 { return __r <= __l; }
419#endif
420
421#if __SIZEOF_INT128__
422 __extension__
423 using __rep = unsigned __int128;
424#else
425 using __rep = unsigned long long;
426#endif
427 static constexpr size_t _S_rep_bits = sizeof(__rep) * __CHAR_BIT__;
428
429 __rep _M_val = 0;
430 unsigned _M_msb:1 = 0;
431
432 private:
433 constexpr explicit
434 __max_size_type(__rep __val, int __msb) noexcept
435 : _M_val(__val), _M_msb(__msb)
436 { }
437
438 friend __max_diff_type;
439 friend std::numeric_limits<__max_size_type>;
440 friend std::numeric_limits<__max_diff_type>;
441 };
442
443 class __max_diff_type
444 {
445 public:
446 __max_diff_type() = default;
447
448 template<typename _Tp> requires integral<_Tp>
449 constexpr
450 __max_diff_type(_Tp __i) noexcept
451 : _M_rep(__i)
452 { }
453
454 constexpr explicit
455 __max_diff_type(const __max_size_type& __d) noexcept
456 : _M_rep(__d)
457 { }
458
459 template<typename _Tp> requires integral<_Tp>
460 constexpr explicit
461 operator _Tp() const noexcept
462 { return static_cast<_Tp>(_M_rep); }
463
464 constexpr explicit
465 operator bool() const noexcept
466 { return _M_rep != 0; }
467
468 constexpr __max_diff_type
469 operator+() const noexcept
470 { return *this; }
471
472 constexpr __max_diff_type
473 operator-() const noexcept
474 { return __max_diff_type(-_M_rep); }
475
476 constexpr __max_diff_type
477 operator~() const noexcept
478 { return __max_diff_type(~_M_rep); }
479
480 constexpr __max_diff_type&
481 operator++() noexcept
482 { return *this += 1; }
483
484 constexpr __max_diff_type
485 operator++(int) noexcept
486 {
487 auto __tmp = *this;
488 ++*this;
489 return __tmp;
490 }
491
492 constexpr __max_diff_type&
493 operator--() noexcept
494 { return *this -= 1; }
495
496 constexpr __max_diff_type
497 operator--(int) noexcept
498 {
499 auto __tmp = *this;
500 --*this;
501 return __tmp;
502 }
503
504 constexpr __max_diff_type&
505 operator+=(const __max_diff_type& __r) noexcept
506 {
507 _M_rep += __r._M_rep;
508 return *this;
509 }
510
511 constexpr __max_diff_type&
512 operator-=(const __max_diff_type& __r) noexcept
513 {
514 _M_rep -= __r._M_rep;
515 return *this;
516 }
517
518 constexpr __max_diff_type&
519 operator*=(const __max_diff_type& __r) noexcept
520 {
521 _M_rep *= __r._M_rep;
522 return *this;
523 }
524
525 constexpr __max_diff_type&
526 operator/=(const __max_diff_type& __r) noexcept
527 {
528 __glibcxx_assert (__r != 0);
529 const bool __neg = *this < 0;
530 const bool __rneg = __r < 0;
531 if (!__neg && !__rneg)
532 _M_rep = _M_rep / __r._M_rep;
533 else if (__neg && __rneg)
534 _M_rep = -_M_rep / -__r._M_rep;
535 else if (__neg && !__rneg)
536 _M_rep = -(-_M_rep / __r._M_rep);
537 else
538 _M_rep = -(_M_rep / -__r._M_rep);
539 return *this ;
540 }
541
542 constexpr __max_diff_type&
543 operator%=(const __max_diff_type& __r) noexcept
544 {
545 __glibcxx_assert (__r != 0);
546 if (*this >= 0 && __r > 0)
547 _M_rep %= __r._M_rep;
548 else
549 *this -= (*this / __r) * __r;
550 return *this;
551 }
552
553 constexpr __max_diff_type&
554 operator<<=(const __max_diff_type& __r) noexcept
555 {
556 _M_rep.operator<<=(__r._M_rep);
557 return *this;
558 }
559
560 constexpr __max_diff_type&
561 operator>>=(const __max_diff_type& __r) noexcept
562 {
563 // Arithmetic right shift.
564 const auto __msb = _M_rep._M_msb;
565 _M_rep >>= __r._M_rep;
566 if (__msb)
567 _M_rep |= ~(__max_size_type(-1) >> __r._M_rep);
568 return *this;
569 }
570
571 constexpr __max_diff_type&
572 operator&=(const __max_diff_type& __r) noexcept
573 {
574 _M_rep &= __r._M_rep;
575 return *this;
576 }
577
578 constexpr __max_diff_type&
579 operator|=(const __max_diff_type& __r) noexcept
580 {
581 _M_rep |= __r._M_rep;
582 return *this;
583 }
584
585 constexpr __max_diff_type&
586 operator^=(const __max_diff_type& __r) noexcept
587 {
588 _M_rep ^= __r._M_rep;
589 return *this;
590 }
591
592 template<typename _Tp> requires integral<_Tp>
593 friend constexpr _Tp&
594 operator+=(_Tp& __a, const __max_diff_type& __b) noexcept
595 { return (__a = static_cast<_Tp>(__a + __b)); }
596
597 template<typename _Tp> requires integral<_Tp>
598 friend constexpr _Tp&
599 operator-=(_Tp& __a, const __max_diff_type& __b) noexcept
600 { return (__a = static_cast<_Tp>(__a - __b)); }
601
602 template<typename _Tp> requires integral<_Tp>
603 friend constexpr _Tp&
604 operator*=(_Tp& __a, const __max_diff_type& __b) noexcept
605 { return (__a = static_cast<_Tp>(__a * __b)); }
606
607 template<typename _Tp> requires integral<_Tp>
608 friend constexpr _Tp&
609 operator/=(_Tp& __a, const __max_diff_type& __b) noexcept
610 { return (__a = static_cast<_Tp>(__a / __b)); }
611
612 template<typename _Tp> requires integral<_Tp>
613 friend constexpr _Tp&
614 operator%=(_Tp& __a, const __max_diff_type& __b) noexcept
615 { return (__a = static_cast<_Tp>(__a % __b)); }
616
617 template<typename _Tp> requires integral<_Tp>
618 friend constexpr _Tp&
619 operator&=(_Tp& __a, const __max_diff_type& __b) noexcept
620 { return (__a = static_cast<_Tp>(__a & __b)); }
621
622 template<typename _Tp> requires integral<_Tp>
623 friend constexpr _Tp&
624 operator|=(_Tp& __a, const __max_diff_type& __b) noexcept
625 { return (__a = static_cast<_Tp>(__a | __b)); }
626
627 template<typename _Tp> requires integral<_Tp>
628 friend constexpr _Tp&
629 operator^=(_Tp& __a, const __max_diff_type& __b) noexcept
630 { return (__a = static_cast<_Tp>(__a ^ __b)); }
631
632 template<typename _Tp> requires integral<_Tp>
633 friend constexpr _Tp&
634 operator<<=(_Tp& __a, const __max_diff_type& __b) noexcept
635 { return (__a = static_cast<_Tp>(__a << __b)); }
636
637 template<typename _Tp> requires integral<_Tp>
638 friend constexpr _Tp&
639 operator>>=(_Tp& __a, const __max_diff_type& __b) noexcept
640 { return (__a = static_cast<_Tp>(__a >> __b)); }
641
642 friend constexpr __max_diff_type
643 operator+(__max_diff_type __l, const __max_diff_type& __r) noexcept
644 {
645 __l += __r;
646 return __l;
647 }
648
649 friend constexpr __max_diff_type
650 operator-(__max_diff_type __l, const __max_diff_type& __r) noexcept
651 {
652 __l -= __r;
653 return __l;
654 }
655
656 friend constexpr __max_diff_type
657 operator*(__max_diff_type __l, const __max_diff_type& __r) noexcept
658 {
659 __l *= __r;
660 return __l;
661 }
662
663 friend constexpr __max_diff_type
664 operator/(__max_diff_type __l, const __max_diff_type& __r) noexcept
665 {
666 __l /= __r;
667 return __l;
668 }
669
670 friend constexpr __max_diff_type
671 operator%(__max_diff_type __l, const __max_diff_type& __r) noexcept
672 {
673 __l %= __r;
674 return __l;
675 }
676
677 friend constexpr __max_diff_type
678 operator<<(__max_diff_type __l, const __max_diff_type& __r) noexcept
679 {
680 __l <<= __r;
681 return __l;
682 }
683
684 friend constexpr __max_diff_type
685 operator>>(__max_diff_type __l, const __max_diff_type& __r) noexcept
686 {
687 __l >>= __r;
688 return __l;
689 }
690
691 friend constexpr __max_diff_type
692 operator&(__max_diff_type __l, const __max_diff_type& __r) noexcept
693 {
694 __l &= __r;
695 return __l;
696 }
697
698 friend constexpr __max_diff_type
699 operator|(__max_diff_type __l, const __max_diff_type& __r) noexcept
700 {
701 __l |= __r;
702 return __l;
703 }
704
705 friend constexpr __max_diff_type
706 operator^(__max_diff_type __l, const __max_diff_type& __r) noexcept
707 {
708 __l ^= __r;
709 return __l;
710 }
711
712 friend constexpr bool
713 operator==(const __max_diff_type& __l, const __max_diff_type& __r) noexcept
714 { return __l._M_rep == __r._M_rep; }
715
716#if __cpp_lib_three_way_comparison
717 constexpr strong_ordering
718 operator<=>(const __max_diff_type& __r) const noexcept
719 {
720 const auto __lsign = _M_rep._M_msb;
721 const auto __rsign = __r._M_rep._M_msb;
722 if (__lsign ^ __rsign)
723 return __lsign ? strong_ordering::less : strong_ordering::greater;
724 else
725 return _M_rep <=> __r._M_rep;
726 }
727#else
728 friend constexpr bool
729 operator!=(const __max_diff_type& __l, const __max_diff_type& __r) noexcept
730 { return !(__l == __r); }
731
732 constexpr bool
733 operator<(const __max_diff_type& __r) const noexcept
734 {
735 const auto __lsign = _M_rep._M_msb;
736 const auto __rsign = __r._M_rep._M_msb;
737 if (__lsign ^ __rsign)
738 return __lsign;
739 else
740 return _M_rep < __r._M_rep;
741 }
742
743 friend constexpr bool
744 operator>(const __max_diff_type& __l, const __max_diff_type& __r) noexcept
745 { return __r < __l; }
746
747 friend constexpr bool
748 operator<=(const __max_diff_type& __l, const __max_diff_type& __r) noexcept
749 { return !(__r < __l); }
750
751 friend constexpr bool
752 operator>=(const __max_diff_type& __l, const __max_diff_type& __r) noexcept
753 { return !(__l < __r); }
754#endif
755
756 __max_size_type _M_rep = 0;
757
758 friend class __max_size_type;
759 };
760
761 constexpr
762 __max_size_type::__max_size_type(const __max_diff_type& __d) noexcept
763 : __max_size_type(__d._M_rep)
764 { }
765
766 } // namespace __detail
767} // namespace ranges
768
769 template<>
770 struct numeric_limits<ranges::__detail::__max_size_type>
771 {
772 using _Sp = ranges::__detail::__max_size_type;
773 static constexpr bool is_specialized = true;
774 static constexpr bool is_signed = false;
775 static constexpr bool is_integer = true;
776 static constexpr bool is_exact = true;
777 static constexpr bool is_bounded = true;
778 static constexpr bool is_modulo = true;
779 static constexpr bool traps = __glibcxx_integral_traps;
780 static constexpr int radix = 2;
781 static constexpr int digits
782 = __gnu_cxx::__int_traits<_Sp::__rep>::__digits + 1;
783 static constexpr int digits10
784 = static_cast<int>(digits * numbers::ln2 / numbers::ln10);
785 static constexpr int max_digits10 = 0;
786 static constexpr int min_exponent = 0;
787 static constexpr int min_exponent10 = 0;
788 static constexpr int max_exponent = 0;
789 static constexpr int max_exponent10 = 0;
790 static constexpr bool is_iec559 = false;
791 static constexpr bool has_infinity = false;
792 static constexpr bool has_quiet_NaN = false;
793 static constexpr bool has_signaling_NaN = false;
794 static constexpr bool has_denorm_loss = false;
795 static constexpr bool tinyness_before = false;
798
799 static constexpr _Sp
800 min() noexcept
801 { return 0; }
802
803 static constexpr _Sp
804 max() noexcept
805 { return _Sp(static_cast<_Sp::__rep>(-1), 1); }
806
807 static constexpr _Sp
808 lowest() noexcept
809 { return min(); }
810
811 static constexpr _Sp
812 denorm_min() noexcept
813 { return 0; }
814
815 static constexpr _Sp
816 epsilon() noexcept
817 { return 0; }
818
819 static constexpr _Sp
820 round_error() noexcept
821 { return 0; }
822
823 static constexpr _Sp
824 infinity() noexcept
825 { return 0; }
826
827 static constexpr _Sp
828 quiet_NaN() noexcept
829 { return 0; }
830
831 static constexpr _Sp
832 signaling_NaN() noexcept
833 { return 0; }
834 };
835
836 template<>
837 struct numeric_limits<ranges::__detail::__max_diff_type>
838 {
839 using _Dp = ranges::__detail::__max_diff_type;
840 using _Sp = ranges::__detail::__max_size_type;
841 static constexpr bool is_specialized = true;
842 static constexpr bool is_signed = true;
843 static constexpr bool is_integer = true;
844 static constexpr bool is_exact = true;
845 static constexpr bool is_bounded = true;
846 static constexpr bool is_modulo = false;
847 static constexpr bool traps = __glibcxx_integral_traps;
848 static constexpr int radix = 2;
849 static constexpr int digits = numeric_limits<_Sp>::digits - 1;
850 static constexpr int digits10
851 = static_cast<int>(digits * numbers::ln2 / numbers::ln10);
852 static constexpr int max_digits10 = 0;
853 static constexpr int min_exponent = 0;
854 static constexpr int min_exponent10 = 0;
855 static constexpr int max_exponent = 0;
856 static constexpr int max_exponent10 = 0;
857 static constexpr bool is_iec559 = false;
858 static constexpr bool has_infinity = false;
859 static constexpr bool has_quiet_NaN = false;
860 static constexpr bool has_signaling_NaN = false;
861 static constexpr bool has_denorm_loss = false;
862 static constexpr bool tinyness_before = false;
865
866 static constexpr _Dp
867 min() noexcept
868 { return _Dp(_Sp(0, 1)); }
869
870 static constexpr _Dp
871 max() noexcept
872 { return _Dp(_Sp(static_cast<_Sp::__rep>(-1), 0)); }
873
874 static constexpr _Dp
875 lowest() noexcept
876 { return min(); }
877
878 static constexpr _Dp
879 denorm_min() noexcept
880 { return 0; }
881
882 static constexpr _Dp
883 epsilon() noexcept
884 { return 0; }
885
886 static constexpr _Dp
887 round_error() noexcept
888 { return 0; }
889
890 static constexpr _Dp
891 infinity() noexcept
892 { return 0; }
893
894 static constexpr _Dp
895 quiet_NaN() noexcept
896 { return 0; }
897
898 static constexpr _Dp
899 signaling_NaN() noexcept
900 { return 0; }
901 };
902
903 template<>
904 inline constexpr int
905 __bit_width(ranges::__detail::__max_size_type __x) noexcept
906 {
907 if (__x._M_msb)
909 else
910 return std::__bit_width(__x._M_val);
911 }
912
913_GLIBCXX_END_NAMESPACE_VERSION
914} // namespace
915
916#endif // C++20 && library concepts
917#endif // _GLIBCXX_MAX_SIZE_TYPE_H
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
Definition chrono.h:859
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
Definition chrono.h:873
constexpr duration< __common_rep_t< _Rep1, __disable_if_is_duration< _Rep2 > >, _Period > operator%(const duration< _Rep1, _Period > &__d, const _Rep2 &__s)
Definition chrono.h:783
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
Definition chrono.h:826
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
Definition chrono.h:866
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
Definition complex:434
constexpr complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
Definition complex:404
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
Definition complex:374
constexpr complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
Definition complex:464
ISO C++ entities toplevel namespace is std.
float_round_style
Describes the rounding style for floating-point types.
Definition limits:175
@ round_toward_zero
To zero.
Definition limits:177
float_denorm_style
Describes the denormalization for floating-point types.
Definition limits:190
@ denorm_absent
The type does not allow denormalized values.
Definition limits:194
constexpr bitset< _Nb > operator^(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition bitset:1624
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
Definition bitset:1644
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
Definition bitset:1740
constexpr bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition bitset:1614
constexpr bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Definition bitset:1604
static constexpr bool is_modulo
Definition limits:295
static constexpr bool has_quiet_NaN
Definition limits:266
static constexpr bool is_integer
Definition limits:233
static constexpr int max_digits10
Definition limits:226
static constexpr int min_exponent
Definition limits:246
static constexpr int digits
Definition limits:218
static constexpr bool is_bounded
Definition limits:286
static constexpr bool has_denorm_loss
Definition limits:277
static constexpr bool is_iec559
Definition limits:281
static constexpr bool is_exact
Definition limits:238
static constexpr bool traps
Definition limits:298
static constexpr bool has_signaling_NaN
Definition limits:270
static constexpr bool is_specialized
Definition limits:213
static constexpr int max_exponent
Definition limits:255
static constexpr bool is_signed
Definition limits:230
static constexpr int digits10
Definition limits:221
static constexpr int min_exponent10
Definition limits:250
static constexpr bool tinyness_before
Definition limits:301
static constexpr float_round_style round_style
Definition limits:306
static constexpr bool has_infinity
Definition limits:262
static constexpr int radix
Definition limits:242
static constexpr int max_exponent10
Definition limits:259
static constexpr float_denorm_style has_denorm
Definition limits:273
Properties of fundamental types.
Definition limits:320
static constexpr _Tp max() noexcept
Definition limits:328
static constexpr _Tp epsilon() noexcept
Definition limits:340
static constexpr _Tp quiet_NaN() noexcept
Definition limits:353
static constexpr _Tp lowest() noexcept
Definition limits:334
static constexpr _Tp min() noexcept
Definition limits:324
static constexpr _Tp denorm_min() noexcept
Definition limits:364
static constexpr _Tp infinity() noexcept
Definition limits:348
static constexpr _Tp round_error() noexcept
Definition limits:344
static constexpr _Tp signaling_NaN() noexcept
Definition limits:358