StormByte 2.0.0
C++26 foundation of the StormByte suite
 
Loading...
Searching...
No Matches
size.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte.
5 *
6 * StormByte original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte source in this repository.
20 * They do not cover other StormByte modules or any third-party material
21 * shipped with this repository (including everything under thirdparty/),
22 * which remains under its own license.
23 *
24 * Neither license grants any patent rights. Any patent licenses required
25 * to use this software or third-party components must be obtained separately
26 * from the patent holders.
27 *
28 * StormByte is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU Lesser General Public License for more details.
32 *
33 * You should have received a copy of the GNU Lesser General Public License
34 * version 3 along with StormByte. If not, see
35 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
36 *
37 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
38 */
39
40#pragma once
41
44
45#include <cassert>
46#include <compare>
47#include <cstddef>
48#include <cstdint>
49#include <limits>
50#include <ostream>
51#include <string>
52#include <type_traits>
53#include <utility>
54
64namespace StormByte {
68 namespace Safe {
69 class String;
70 class WString;
71 }
72 class ByteSize;
73
105 class STORMBYTE_PUBLIC Size final {
106 public:
110 constexpr Size() noexcept: m_value(0) {}
111
117 template<Type::Integral T>
118 constexpr Size(T value) noexcept: m_value(FromIntegral(value)) {}
119
124 constexpr Size(const Size& other) noexcept = default;
125
130 constexpr Size(Size&& other) noexcept = default;
131
135 constexpr ~Size() noexcept = default;
136
142 constexpr Size& operator=(const Size& other) noexcept = default;
143
149 constexpr Size& operator=(Size&& other) noexcept = default;
150
157 template<Type::Integral T>
158 constexpr Size& operator=(T value) noexcept {
159 m_value = FromIntegral(value);
160 return *this;
161 }
162
167 constexpr operator std::size_t() const noexcept {
168 constexpr auto max = static_cast<std::uint64_t>(std::numeric_limits<std::size_t>::max());
169 return static_cast<std::size_t>(m_value > max ? max : m_value);
170 }
171
177 template<Type::Integral T>
179 constexpr explicit operator T() const noexcept {
180 constexpr auto max = static_cast<std::uint64_t>(std::numeric_limits<T>::max());
181 return static_cast<T>(m_value > max ? max : m_value);
182 }
183
188 explicit operator Safe::String() const noexcept;
189
194 explicit operator Safe::WString() const noexcept;
195
200 STORMBYTE_FORCE_INLINE operator std::string() const {
201 return std::to_string(m_value);
202 }
203
210 friend constexpr bool operator==(Size lhs, Size rhs) noexcept {
211 return lhs.m_value == rhs.m_value;
212 }
213
218 template<Type::Integral T>
219 friend constexpr bool operator==(Size lhs, T rhs) noexcept;
220
225 template<Type::Integral T>
226 friend constexpr bool operator==(T lhs, Size rhs) noexcept;
227
234 friend constexpr std::strong_ordering operator<=>(Size lhs, Size rhs) noexcept {
235 return lhs.m_value <=> rhs.m_value;
236 }
237
242 template<Type::Integral T>
243 friend constexpr std::strong_ordering operator<=>(Size lhs, T rhs) noexcept;
244
249 template<Type::Integral T>
250 friend constexpr std::strong_ordering operator<=>(T lhs, Size rhs) noexcept;
251
256 constexpr Size& operator++() noexcept {
257 *this += Size(Raw{}, 1);
258 return *this;
259 }
260
265 constexpr Size operator++(int) noexcept {
266 const Size old = *this;
267 ++*this;
268 return old;
269 }
270
275 constexpr Size& operator--() noexcept {
276 *this -= Size(Raw{}, 1);
277 return *this;
278 }
279
284 constexpr Size operator--(int) noexcept {
285 const Size old = *this;
286 --*this;
287 return old;
288 }
289
296 friend constexpr Size operator+(Size lhs, Size rhs) noexcept {
297 return Size(Raw{}, Add(lhs.m_value, rhs.m_value));
298 }
299
306 friend constexpr Size operator-(Size lhs, Size rhs) noexcept {
307 return Size(Raw{}, Sub(lhs.m_value, rhs.m_value));
308 }
309
316 friend constexpr Size operator*(Size lhs, Size rhs) noexcept {
317 return Size(Raw{}, Mul(lhs.m_value, rhs.m_value));
318 }
319
326 friend constexpr Size operator/(Size lhs, Size rhs) noexcept {
327 return Size(Raw{}, Div(lhs.m_value, rhs.m_value));
328 }
329
336 friend constexpr Size operator%(Size lhs, Size rhs) noexcept {
337 return Size(Raw{}, Mod(lhs.m_value, rhs.m_value));
338 }
339
345 constexpr Size& operator+=(Size other) noexcept {
346 m_value = Add(m_value, other.m_value);
347 return *this;
348 }
349
355 constexpr Size& operator-=(Size other) noexcept {
356 m_value = Sub(m_value, other.m_value);
357 return *this;
358 }
359
365 constexpr Size& operator*=(Size other) noexcept {
366 m_value = Mul(m_value, other.m_value);
367 return *this;
368 }
369
375 constexpr Size& operator/=(Size other) noexcept {
376 m_value = Div(m_value, other.m_value);
377 return *this;
378 }
379
385 constexpr Size& operator%=(Size other) noexcept {
386 m_value = Mod(m_value, other.m_value);
387 return *this;
388 }
389
394 template<Type::Integral T>
395 friend constexpr Size operator+(Size lhs, T rhs) noexcept;
396
401 template<Type::Integral T>
402 friend constexpr Size operator+(T lhs, Size rhs) noexcept;
403
408 template<Type::Integral T>
409 friend constexpr Size operator-(Size lhs, T rhs) noexcept;
410
415 template<Type::Integral T>
416 friend constexpr Size operator-(T lhs, Size rhs) noexcept;
417
422 template<Type::Integral T>
423 friend constexpr Size operator*(Size lhs, T rhs) noexcept;
424
429 template<Type::Integral T>
430 friend constexpr Size operator*(T lhs, Size rhs) noexcept;
431
436 template<Type::Integral T>
437 friend constexpr Size operator/(Size lhs, T rhs) noexcept;
438
443 template<Type::Integral T>
444 friend constexpr Size operator/(T lhs, Size rhs) noexcept;
445
450 template<Type::Integral T>
451 friend constexpr Size operator%(Size lhs, T rhs) noexcept;
452
457 template<Type::Integral T>
458 friend constexpr Size operator%(T lhs, Size rhs) noexcept;
459
466 template<Type::Integral T>
467 constexpr Size& operator+=(T value) noexcept {
468 *this = *this + value;
469 return *this;
470 }
471
478 template<Type::Integral T>
479 constexpr Size& operator-=(T value) noexcept {
480 *this = *this - value;
481 return *this;
482 }
483
490 template<Type::Integral T>
491 constexpr Size& operator*=(T value) noexcept {
492 *this = *this * value;
493 return *this;
494 }
495
502 template<Type::Integral T>
503 constexpr Size& operator/=(T value) noexcept {
504 *this = *this / value;
505 return *this;
506 }
507
514 template<Type::Integral T>
515 constexpr Size& operator%=(T value) noexcept {
516 *this = *this % value;
517 return *this;
518 }
519
520 private:
521 std::uint64_t m_value;
522
526 struct Raw {
527 explicit constexpr Raw() noexcept = default;
528 };
529
534 explicit constexpr Size(Raw, std::uint64_t value) noexcept: m_value(value) {}
535
542 template<Type::Integral T>
543 static constexpr std::uint64_t FromIntegral(T value) noexcept {
544 if constexpr (Type::Signed<T>)
545 assert(value >= T{0});
546 return static_cast<std::uint64_t>(value);
547 }
548
555 static constexpr std::uint64_t Add(std::uint64_t lhs, std::uint64_t rhs) noexcept {
556 assert(lhs <= std::numeric_limits<std::uint64_t>::max() - rhs);
557 return lhs + rhs;
558 }
559
566 static constexpr std::uint64_t Sub(std::uint64_t lhs, std::uint64_t rhs) noexcept {
567 assert(lhs >= rhs);
568 return lhs - rhs;
569 }
570
577 static constexpr std::uint64_t Mul(std::uint64_t lhs, std::uint64_t rhs) noexcept {
578 assert(rhs == 0 || lhs <= std::numeric_limits<std::uint64_t>::max() / rhs);
579 return lhs * rhs;
580 }
581
588 static constexpr std::uint64_t Div(std::uint64_t lhs, std::uint64_t rhs) noexcept {
589 assert(rhs != 0);
590 return lhs / rhs;
591 }
592
599 static constexpr std::uint64_t Mod(std::uint64_t lhs, std::uint64_t rhs) noexcept {
600 assert(rhs != 0);
601 return lhs % rhs;
602 }
603
611 template<Type::Integral T>
612 static constexpr Size MixAdd(std::uint64_t lhs, T rhs) noexcept {
613 if constexpr (Type::Signed<T>) {
614 if (rhs < T{0}) {
615 const auto mag = static_cast<std::uint64_t>(0) - static_cast<std::uint64_t>(rhs);
616 return Size(Raw{}, Sub(lhs, mag));
617 }
618 }
619 return Size(Raw{}, Add(lhs, static_cast<std::uint64_t>(rhs)));
620 }
621
629 template<Type::Integral T>
630 static constexpr Size MixSub(std::uint64_t lhs, T rhs) noexcept {
631 if constexpr (Type::Signed<T>) {
632 if (rhs < T{0}) {
633 const auto mag = static_cast<std::uint64_t>(0) - static_cast<std::uint64_t>(rhs);
634 return Size(Raw{}, Add(lhs, mag));
635 }
636 }
637 return Size(Raw{}, Sub(lhs, static_cast<std::uint64_t>(rhs)));
638 }
639
647 template<Type::Integral T>
648 static constexpr Size MixMul(std::uint64_t lhs, T rhs) noexcept {
649 if constexpr (Type::Signed<T>)
650 assert(rhs >= T{0});
651 return Size(Raw{}, Mul(lhs, static_cast<std::uint64_t>(rhs)));
652 }
653 };
654
662 template<Type::Integral T>
663 constexpr bool operator==(Size lhs, T rhs) noexcept {
664 return lhs == Size(rhs);
665 }
666
674 template<Type::Integral T>
675 constexpr bool operator==(T lhs, Size rhs) noexcept {
676 return Size(lhs) == rhs;
677 }
678
686 template<Type::Integral T>
687 constexpr std::strong_ordering operator<=>(Size lhs, T rhs) noexcept {
688 return lhs <=> Size(rhs);
689 }
690
698 template<Type::Integral T>
699 constexpr std::strong_ordering operator<=>(T lhs, Size rhs) noexcept {
700 return Size(lhs) <=> rhs;
701 }
702
710 template<Type::Integral T>
711 constexpr Size operator+(Size lhs, T rhs) noexcept {
712 return Size::MixAdd(lhs.m_value, rhs);
713 }
714
722 template<Type::Integral T>
723 constexpr Size operator+(T lhs, Size rhs) noexcept {
724 return Size::MixAdd(rhs.m_value, lhs);
725 }
726
734 template<Type::Integral T>
735 constexpr Size operator-(Size lhs, T rhs) noexcept {
736 return Size::MixSub(lhs.m_value, rhs);
737 }
738
746 template<Type::Integral T>
747 constexpr Size operator-(T lhs, Size rhs) noexcept {
748 return Size(lhs) - rhs;
749 }
750
758 template<Type::Integral T>
759 constexpr Size operator*(Size lhs, T rhs) noexcept {
760 return Size::MixMul(lhs.m_value, rhs);
761 }
762
770 template<Type::Integral T>
771 constexpr Size operator*(T lhs, Size rhs) noexcept {
772 return Size::MixMul(rhs.m_value, lhs);
773 }
774
782 template<Type::Integral T>
783 constexpr Size operator/(Size lhs, T rhs) noexcept {
784 return lhs / Size(rhs);
785 }
786
794 template<Type::Integral T>
795 constexpr Size operator/(T lhs, Size rhs) noexcept {
796 return Size(lhs) / rhs;
797 }
798
806 template<Type::Integral T>
807 constexpr Size operator%(Size lhs, T rhs) noexcept {
808 return lhs % Size(rhs);
809 }
810
818 template<Type::Integral T>
819 constexpr Size operator%(T lhs, Size rhs) noexcept {
820 return Size(lhs) % rhs;
821 }
822
829 inline std::ostream& operator<<(std::ostream& stream, Size size) {
830 stream << static_cast<std::string>(size);
831 return stream;
832 }
833
835 extern template STORMBYTE_PUBLIC Size& Size::operator=(char) noexcept;
836 extern template STORMBYTE_PUBLIC Size& Size::operator=(signed char) noexcept;
837 extern template STORMBYTE_PUBLIC Size& Size::operator=(unsigned char) noexcept;
838 extern template STORMBYTE_PUBLIC Size& Size::operator=(short) noexcept;
839 extern template STORMBYTE_PUBLIC Size& Size::operator=(unsigned short) noexcept;
840 extern template STORMBYTE_PUBLIC Size& Size::operator=(int) noexcept;
841 extern template STORMBYTE_PUBLIC Size& Size::operator=(unsigned int) noexcept;
842 extern template STORMBYTE_PUBLIC Size& Size::operator=(long) noexcept;
843 extern template STORMBYTE_PUBLIC Size& Size::operator=(unsigned long) noexcept;
844 extern template STORMBYTE_PUBLIC Size& Size::operator=(long long) noexcept;
845 extern template STORMBYTE_PUBLIC Size& Size::operator=(unsigned long long) noexcept;
846 extern template STORMBYTE_PUBLIC Size& Size::operator=(wchar_t) noexcept;
847 extern template STORMBYTE_PUBLIC Size& Size::operator=(char8_t) noexcept;
848 extern template STORMBYTE_PUBLIC Size& Size::operator=(char16_t) noexcept;
849 extern template STORMBYTE_PUBLIC Size& Size::operator=(char32_t) noexcept;
850
851 extern template STORMBYTE_PUBLIC Size& Size::operator+=(char) noexcept;
852 extern template STORMBYTE_PUBLIC Size& Size::operator+=(signed char) noexcept;
853 extern template STORMBYTE_PUBLIC Size& Size::operator+=(unsigned char) noexcept;
854 extern template STORMBYTE_PUBLIC Size& Size::operator+=(short) noexcept;
855 extern template STORMBYTE_PUBLIC Size& Size::operator+=(unsigned short) noexcept;
856 extern template STORMBYTE_PUBLIC Size& Size::operator+=(int) noexcept;
857 extern template STORMBYTE_PUBLIC Size& Size::operator+=(unsigned int) noexcept;
858 extern template STORMBYTE_PUBLIC Size& Size::operator+=(long) noexcept;
859 extern template STORMBYTE_PUBLIC Size& Size::operator+=(unsigned long) noexcept;
860 extern template STORMBYTE_PUBLIC Size& Size::operator+=(long long) noexcept;
861 extern template STORMBYTE_PUBLIC Size& Size::operator+=(unsigned long long) noexcept;
862 extern template STORMBYTE_PUBLIC Size& Size::operator+=(wchar_t) noexcept;
863 extern template STORMBYTE_PUBLIC Size& Size::operator+=(char8_t) noexcept;
864 extern template STORMBYTE_PUBLIC Size& Size::operator+=(char16_t) noexcept;
865 extern template STORMBYTE_PUBLIC Size& Size::operator+=(char32_t) noexcept;
866
867 extern template STORMBYTE_PUBLIC Size& Size::operator-=(char) noexcept;
868 extern template STORMBYTE_PUBLIC Size& Size::operator-=(signed char) noexcept;
869 extern template STORMBYTE_PUBLIC Size& Size::operator-=(unsigned char) noexcept;
870 extern template STORMBYTE_PUBLIC Size& Size::operator-=(short) noexcept;
871 extern template STORMBYTE_PUBLIC Size& Size::operator-=(unsigned short) noexcept;
872 extern template STORMBYTE_PUBLIC Size& Size::operator-=(int) noexcept;
873 extern template STORMBYTE_PUBLIC Size& Size::operator-=(unsigned int) noexcept;
874 extern template STORMBYTE_PUBLIC Size& Size::operator-=(long) noexcept;
875 extern template STORMBYTE_PUBLIC Size& Size::operator-=(unsigned long) noexcept;
876 extern template STORMBYTE_PUBLIC Size& Size::operator-=(long long) noexcept;
877 extern template STORMBYTE_PUBLIC Size& Size::operator-=(unsigned long long) noexcept;
878 extern template STORMBYTE_PUBLIC Size& Size::operator-=(wchar_t) noexcept;
879 extern template STORMBYTE_PUBLIC Size& Size::operator-=(char8_t) noexcept;
880 extern template STORMBYTE_PUBLIC Size& Size::operator-=(char16_t) noexcept;
881 extern template STORMBYTE_PUBLIC Size& Size::operator-=(char32_t) noexcept;
882
883 extern template STORMBYTE_PUBLIC Size& Size::operator*=(char) noexcept;
884 extern template STORMBYTE_PUBLIC Size& Size::operator*=(signed char) noexcept;
885 extern template STORMBYTE_PUBLIC Size& Size::operator*=(unsigned char) noexcept;
886 extern template STORMBYTE_PUBLIC Size& Size::operator*=(short) noexcept;
887 extern template STORMBYTE_PUBLIC Size& Size::operator*=(unsigned short) noexcept;
888 extern template STORMBYTE_PUBLIC Size& Size::operator*=(int) noexcept;
889 extern template STORMBYTE_PUBLIC Size& Size::operator*=(unsigned int) noexcept;
890 extern template STORMBYTE_PUBLIC Size& Size::operator*=(long) noexcept;
891 extern template STORMBYTE_PUBLIC Size& Size::operator*=(unsigned long) noexcept;
892 extern template STORMBYTE_PUBLIC Size& Size::operator*=(long long) noexcept;
893 extern template STORMBYTE_PUBLIC Size& Size::operator*=(unsigned long long) noexcept;
894 extern template STORMBYTE_PUBLIC Size& Size::operator*=(wchar_t) noexcept;
895 extern template STORMBYTE_PUBLIC Size& Size::operator*=(char8_t) noexcept;
896 extern template STORMBYTE_PUBLIC Size& Size::operator*=(char16_t) noexcept;
897 extern template STORMBYTE_PUBLIC Size& Size::operator*=(char32_t) noexcept;
898
899 extern template STORMBYTE_PUBLIC Size& Size::operator/=(char) noexcept;
900 extern template STORMBYTE_PUBLIC Size& Size::operator/=(signed char) noexcept;
901 extern template STORMBYTE_PUBLIC Size& Size::operator/=(unsigned char) noexcept;
902 extern template STORMBYTE_PUBLIC Size& Size::operator/=(short) noexcept;
903 extern template STORMBYTE_PUBLIC Size& Size::operator/=(unsigned short) noexcept;
904 extern template STORMBYTE_PUBLIC Size& Size::operator/=(int) noexcept;
905 extern template STORMBYTE_PUBLIC Size& Size::operator/=(unsigned int) noexcept;
906 extern template STORMBYTE_PUBLIC Size& Size::operator/=(long) noexcept;
907 extern template STORMBYTE_PUBLIC Size& Size::operator/=(unsigned long) noexcept;
908 extern template STORMBYTE_PUBLIC Size& Size::operator/=(long long) noexcept;
909 extern template STORMBYTE_PUBLIC Size& Size::operator/=(unsigned long long) noexcept;
910 extern template STORMBYTE_PUBLIC Size& Size::operator/=(wchar_t) noexcept;
911 extern template STORMBYTE_PUBLIC Size& Size::operator/=(char8_t) noexcept;
912 extern template STORMBYTE_PUBLIC Size& Size::operator/=(char16_t) noexcept;
913 extern template STORMBYTE_PUBLIC Size& Size::operator/=(char32_t) noexcept;
914
915 extern template STORMBYTE_PUBLIC Size& Size::operator%=(char) noexcept;
916 extern template STORMBYTE_PUBLIC Size& Size::operator%=(signed char) noexcept;
917 extern template STORMBYTE_PUBLIC Size& Size::operator%=(unsigned char) noexcept;
918 extern template STORMBYTE_PUBLIC Size& Size::operator%=(short) noexcept;
919 extern template STORMBYTE_PUBLIC Size& Size::operator%=(unsigned short) noexcept;
920 extern template STORMBYTE_PUBLIC Size& Size::operator%=(int) noexcept;
921 extern template STORMBYTE_PUBLIC Size& Size::operator%=(unsigned int) noexcept;
922 extern template STORMBYTE_PUBLIC Size& Size::operator%=(long) noexcept;
923 extern template STORMBYTE_PUBLIC Size& Size::operator%=(unsigned long) noexcept;
924 extern template STORMBYTE_PUBLIC Size& Size::operator%=(long long) noexcept;
925 extern template STORMBYTE_PUBLIC Size& Size::operator%=(unsigned long long) noexcept;
926 extern template STORMBYTE_PUBLIC Size& Size::operator%=(wchar_t) noexcept;
927 extern template STORMBYTE_PUBLIC Size& Size::operator%=(char8_t) noexcept;
928 extern template STORMBYTE_PUBLIC Size& Size::operator%=(char16_t) noexcept;
929 extern template STORMBYTE_PUBLIC Size& Size::operator%=(char32_t) noexcept;
930
931 extern template STORMBYTE_PUBLIC Size::operator char() const noexcept;
932 extern template STORMBYTE_PUBLIC Size::operator signed char() const noexcept;
933 extern template STORMBYTE_PUBLIC Size::operator unsigned char() const noexcept;
934 extern template STORMBYTE_PUBLIC Size::operator short() const noexcept;
935 extern template STORMBYTE_PUBLIC Size::operator unsigned short() const noexcept;
936 extern template STORMBYTE_PUBLIC Size::operator int() const noexcept;
937 extern template STORMBYTE_PUBLIC Size::operator unsigned int() const noexcept;
938 extern template STORMBYTE_PUBLIC Size::operator long() const noexcept;
939 extern template STORMBYTE_PUBLIC Size::operator long long() const noexcept;
940 extern template STORMBYTE_PUBLIC Size::operator wchar_t() const noexcept;
941 extern template STORMBYTE_PUBLIC Size::operator char8_t() const noexcept;
942 extern template STORMBYTE_PUBLIC Size::operator char16_t() const noexcept;
943 extern template STORMBYTE_PUBLIC Size::operator char32_t() const noexcept;
944
945 extern template STORMBYTE_PUBLIC bool operator==(Size, char) noexcept;
946 extern template STORMBYTE_PUBLIC bool operator==(Size, signed char) noexcept;
947 extern template STORMBYTE_PUBLIC bool operator==(Size, unsigned char) noexcept;
948 extern template STORMBYTE_PUBLIC bool operator==(Size, short) noexcept;
949 extern template STORMBYTE_PUBLIC bool operator==(Size, unsigned short) noexcept;
950 extern template STORMBYTE_PUBLIC bool operator==(Size, int) noexcept;
951 extern template STORMBYTE_PUBLIC bool operator==(Size, unsigned int) noexcept;
952 extern template STORMBYTE_PUBLIC bool operator==(Size, long) noexcept;
953 extern template STORMBYTE_PUBLIC bool operator==(Size, unsigned long) noexcept;
954 extern template STORMBYTE_PUBLIC bool operator==(Size, long long) noexcept;
955 extern template STORMBYTE_PUBLIC bool operator==(Size, unsigned long long) noexcept;
956 extern template STORMBYTE_PUBLIC bool operator==(Size, wchar_t) noexcept;
957 extern template STORMBYTE_PUBLIC bool operator==(Size, char8_t) noexcept;
958 extern template STORMBYTE_PUBLIC bool operator==(Size, char16_t) noexcept;
959 extern template STORMBYTE_PUBLIC bool operator==(Size, char32_t) noexcept;
960
961 extern template STORMBYTE_PUBLIC bool operator==(char, Size) noexcept;
962 extern template STORMBYTE_PUBLIC bool operator==(signed char, Size) noexcept;
963 extern template STORMBYTE_PUBLIC bool operator==(unsigned char, Size) noexcept;
964 extern template STORMBYTE_PUBLIC bool operator==(short, Size) noexcept;
965 extern template STORMBYTE_PUBLIC bool operator==(unsigned short, Size) noexcept;
966 extern template STORMBYTE_PUBLIC bool operator==(int, Size) noexcept;
967 extern template STORMBYTE_PUBLIC bool operator==(unsigned int, Size) noexcept;
968 extern template STORMBYTE_PUBLIC bool operator==(long, Size) noexcept;
969 extern template STORMBYTE_PUBLIC bool operator==(unsigned long, Size) noexcept;
970 extern template STORMBYTE_PUBLIC bool operator==(long long, Size) noexcept;
971 extern template STORMBYTE_PUBLIC bool operator==(unsigned long long, Size) noexcept;
972 extern template STORMBYTE_PUBLIC bool operator==(wchar_t, Size) noexcept;
973 extern template STORMBYTE_PUBLIC bool operator==(char8_t, Size) noexcept;
974 extern template STORMBYTE_PUBLIC bool operator==(char16_t, Size) noexcept;
975 extern template STORMBYTE_PUBLIC bool operator==(char32_t, Size) noexcept;
976
977 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, char) noexcept;
978 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, signed char) noexcept;
979 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, unsigned char) noexcept;
980 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, short) noexcept;
981 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, unsigned short) noexcept;
982 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, int) noexcept;
983 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, unsigned int) noexcept;
984 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, long) noexcept;
985 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, unsigned long) noexcept;
986 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, long long) noexcept;
987 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, unsigned long long) noexcept;
988 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, wchar_t) noexcept;
989 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, char8_t) noexcept;
990 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, char16_t) noexcept;
991 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(Size, char32_t) noexcept;
992
993 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(char, Size) noexcept;
994 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(signed char, Size) noexcept;
995 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(unsigned char, Size) noexcept;
996 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(short, Size) noexcept;
997 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(unsigned short, Size) noexcept;
998 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(int, Size) noexcept;
999 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(unsigned int, Size) noexcept;
1000 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(long, Size) noexcept;
1001 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(unsigned long, Size) noexcept;
1002 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(long long, Size) noexcept;
1003 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(unsigned long long, Size) noexcept;
1004 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(wchar_t, Size) noexcept;
1005 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(char8_t, Size) noexcept;
1006 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(char16_t, Size) noexcept;
1007 extern template STORMBYTE_PUBLIC std::strong_ordering operator<=>(char32_t, Size) noexcept;
1008
1009 extern template STORMBYTE_PUBLIC Size operator+(Size, char) noexcept;
1010 extern template STORMBYTE_PUBLIC Size operator+(Size, signed char) noexcept;
1011 extern template STORMBYTE_PUBLIC Size operator+(Size, unsigned char) noexcept;
1012 extern template STORMBYTE_PUBLIC Size operator+(Size, short) noexcept;
1013 extern template STORMBYTE_PUBLIC Size operator+(Size, unsigned short) noexcept;
1014 extern template STORMBYTE_PUBLIC Size operator+(Size, int) noexcept;
1015 extern template STORMBYTE_PUBLIC Size operator+(Size, unsigned int) noexcept;
1016 extern template STORMBYTE_PUBLIC Size operator+(Size, long) noexcept;
1017 extern template STORMBYTE_PUBLIC Size operator+(Size, unsigned long) noexcept;
1018 extern template STORMBYTE_PUBLIC Size operator+(Size, long long) noexcept;
1019 extern template STORMBYTE_PUBLIC Size operator+(Size, unsigned long long) noexcept;
1020 extern template STORMBYTE_PUBLIC Size operator+(Size, wchar_t) noexcept;
1021 extern template STORMBYTE_PUBLIC Size operator+(Size, char8_t) noexcept;
1022 extern template STORMBYTE_PUBLIC Size operator+(Size, char16_t) noexcept;
1023 extern template STORMBYTE_PUBLIC Size operator+(Size, char32_t) noexcept;
1024
1025 extern template STORMBYTE_PUBLIC Size operator+(char, Size) noexcept;
1026 extern template STORMBYTE_PUBLIC Size operator+(signed char, Size) noexcept;
1027 extern template STORMBYTE_PUBLIC Size operator+(unsigned char, Size) noexcept;
1028 extern template STORMBYTE_PUBLIC Size operator+(short, Size) noexcept;
1029 extern template STORMBYTE_PUBLIC Size operator+(unsigned short, Size) noexcept;
1030 extern template STORMBYTE_PUBLIC Size operator+(int, Size) noexcept;
1031 extern template STORMBYTE_PUBLIC Size operator+(unsigned int, Size) noexcept;
1032 extern template STORMBYTE_PUBLIC Size operator+(long, Size) noexcept;
1033 extern template STORMBYTE_PUBLIC Size operator+(unsigned long, Size) noexcept;
1034 extern template STORMBYTE_PUBLIC Size operator+(long long, Size) noexcept;
1035 extern template STORMBYTE_PUBLIC Size operator+(unsigned long long, Size) noexcept;
1036 extern template STORMBYTE_PUBLIC Size operator+(wchar_t, Size) noexcept;
1037 extern template STORMBYTE_PUBLIC Size operator+(char8_t, Size) noexcept;
1038 extern template STORMBYTE_PUBLIC Size operator+(char16_t, Size) noexcept;
1039 extern template STORMBYTE_PUBLIC Size operator+(char32_t, Size) noexcept;
1040
1041 extern template STORMBYTE_PUBLIC Size operator-(Size, char) noexcept;
1042 extern template STORMBYTE_PUBLIC Size operator-(Size, signed char) noexcept;
1043 extern template STORMBYTE_PUBLIC Size operator-(Size, unsigned char) noexcept;
1044 extern template STORMBYTE_PUBLIC Size operator-(Size, short) noexcept;
1045 extern template STORMBYTE_PUBLIC Size operator-(Size, unsigned short) noexcept;
1046 extern template STORMBYTE_PUBLIC Size operator-(Size, int) noexcept;
1047 extern template STORMBYTE_PUBLIC Size operator-(Size, unsigned int) noexcept;
1048 extern template STORMBYTE_PUBLIC Size operator-(Size, long) noexcept;
1049 extern template STORMBYTE_PUBLIC Size operator-(Size, unsigned long) noexcept;
1050 extern template STORMBYTE_PUBLIC Size operator-(Size, long long) noexcept;
1051 extern template STORMBYTE_PUBLIC Size operator-(Size, unsigned long long) noexcept;
1052 extern template STORMBYTE_PUBLIC Size operator-(Size, wchar_t) noexcept;
1053 extern template STORMBYTE_PUBLIC Size operator-(Size, char8_t) noexcept;
1054 extern template STORMBYTE_PUBLIC Size operator-(Size, char16_t) noexcept;
1055 extern template STORMBYTE_PUBLIC Size operator-(Size, char32_t) noexcept;
1056
1057 extern template STORMBYTE_PUBLIC Size operator-(char, Size) noexcept;
1058 extern template STORMBYTE_PUBLIC Size operator-(signed char, Size) noexcept;
1059 extern template STORMBYTE_PUBLIC Size operator-(unsigned char, Size) noexcept;
1060 extern template STORMBYTE_PUBLIC Size operator-(short, Size) noexcept;
1061 extern template STORMBYTE_PUBLIC Size operator-(unsigned short, Size) noexcept;
1062 extern template STORMBYTE_PUBLIC Size operator-(int, Size) noexcept;
1063 extern template STORMBYTE_PUBLIC Size operator-(unsigned int, Size) noexcept;
1064 extern template STORMBYTE_PUBLIC Size operator-(long, Size) noexcept;
1065 extern template STORMBYTE_PUBLIC Size operator-(unsigned long, Size) noexcept;
1066 extern template STORMBYTE_PUBLIC Size operator-(long long, Size) noexcept;
1067 extern template STORMBYTE_PUBLIC Size operator-(unsigned long long, Size) noexcept;
1068 extern template STORMBYTE_PUBLIC Size operator-(wchar_t, Size) noexcept;
1069 extern template STORMBYTE_PUBLIC Size operator-(char8_t, Size) noexcept;
1070 extern template STORMBYTE_PUBLIC Size operator-(char16_t, Size) noexcept;
1071 extern template STORMBYTE_PUBLIC Size operator-(char32_t, Size) noexcept;
1072
1073 extern template STORMBYTE_PUBLIC Size operator*(Size, char) noexcept;
1074 extern template STORMBYTE_PUBLIC Size operator*(Size, signed char) noexcept;
1075 extern template STORMBYTE_PUBLIC Size operator*(Size, unsigned char) noexcept;
1076 extern template STORMBYTE_PUBLIC Size operator*(Size, short) noexcept;
1077 extern template STORMBYTE_PUBLIC Size operator*(Size, unsigned short) noexcept;
1078 extern template STORMBYTE_PUBLIC Size operator*(Size, int) noexcept;
1079 extern template STORMBYTE_PUBLIC Size operator*(Size, unsigned int) noexcept;
1080 extern template STORMBYTE_PUBLIC Size operator*(Size, long) noexcept;
1081 extern template STORMBYTE_PUBLIC Size operator*(Size, unsigned long) noexcept;
1082 extern template STORMBYTE_PUBLIC Size operator*(Size, long long) noexcept;
1083 extern template STORMBYTE_PUBLIC Size operator*(Size, unsigned long long) noexcept;
1084 extern template STORMBYTE_PUBLIC Size operator*(Size, wchar_t) noexcept;
1085 extern template STORMBYTE_PUBLIC Size operator*(Size, char8_t) noexcept;
1086 extern template STORMBYTE_PUBLIC Size operator*(Size, char16_t) noexcept;
1087 extern template STORMBYTE_PUBLIC Size operator*(Size, char32_t) noexcept;
1088
1089 extern template STORMBYTE_PUBLIC Size operator*(char, Size) noexcept;
1090 extern template STORMBYTE_PUBLIC Size operator*(signed char, Size) noexcept;
1091 extern template STORMBYTE_PUBLIC Size operator*(unsigned char, Size) noexcept;
1092 extern template STORMBYTE_PUBLIC Size operator*(short, Size) noexcept;
1093 extern template STORMBYTE_PUBLIC Size operator*(unsigned short, Size) noexcept;
1094 extern template STORMBYTE_PUBLIC Size operator*(int, Size) noexcept;
1095 extern template STORMBYTE_PUBLIC Size operator*(unsigned int, Size) noexcept;
1096 extern template STORMBYTE_PUBLIC Size operator*(long, Size) noexcept;
1097 extern template STORMBYTE_PUBLIC Size operator*(unsigned long, Size) noexcept;
1098 extern template STORMBYTE_PUBLIC Size operator*(long long, Size) noexcept;
1099 extern template STORMBYTE_PUBLIC Size operator*(unsigned long long, Size) noexcept;
1100 extern template STORMBYTE_PUBLIC Size operator*(wchar_t, Size) noexcept;
1101 extern template STORMBYTE_PUBLIC Size operator*(char8_t, Size) noexcept;
1102 extern template STORMBYTE_PUBLIC Size operator*(char16_t, Size) noexcept;
1103 extern template STORMBYTE_PUBLIC Size operator*(char32_t, Size) noexcept;
1104
1105 extern template STORMBYTE_PUBLIC Size operator/(Size, char) noexcept;
1106 extern template STORMBYTE_PUBLIC Size operator/(Size, signed char) noexcept;
1107 extern template STORMBYTE_PUBLIC Size operator/(Size, unsigned char) noexcept;
1108 extern template STORMBYTE_PUBLIC Size operator/(Size, short) noexcept;
1109 extern template STORMBYTE_PUBLIC Size operator/(Size, unsigned short) noexcept;
1110 extern template STORMBYTE_PUBLIC Size operator/(Size, int) noexcept;
1111 extern template STORMBYTE_PUBLIC Size operator/(Size, unsigned int) noexcept;
1112 extern template STORMBYTE_PUBLIC Size operator/(Size, long) noexcept;
1113 extern template STORMBYTE_PUBLIC Size operator/(Size, unsigned long) noexcept;
1114 extern template STORMBYTE_PUBLIC Size operator/(Size, long long) noexcept;
1115 extern template STORMBYTE_PUBLIC Size operator/(Size, unsigned long long) noexcept;
1116 extern template STORMBYTE_PUBLIC Size operator/(Size, wchar_t) noexcept;
1117 extern template STORMBYTE_PUBLIC Size operator/(Size, char8_t) noexcept;
1118 extern template STORMBYTE_PUBLIC Size operator/(Size, char16_t) noexcept;
1119 extern template STORMBYTE_PUBLIC Size operator/(Size, char32_t) noexcept;
1120
1121 extern template STORMBYTE_PUBLIC Size operator/(char, Size) noexcept;
1122 extern template STORMBYTE_PUBLIC Size operator/(signed char, Size) noexcept;
1123 extern template STORMBYTE_PUBLIC Size operator/(unsigned char, Size) noexcept;
1124 extern template STORMBYTE_PUBLIC Size operator/(short, Size) noexcept;
1125 extern template STORMBYTE_PUBLIC Size operator/(unsigned short, Size) noexcept;
1126 extern template STORMBYTE_PUBLIC Size operator/(int, Size) noexcept;
1127 extern template STORMBYTE_PUBLIC Size operator/(unsigned int, Size) noexcept;
1128 extern template STORMBYTE_PUBLIC Size operator/(long, Size) noexcept;
1129 extern template STORMBYTE_PUBLIC Size operator/(unsigned long, Size) noexcept;
1130 extern template STORMBYTE_PUBLIC Size operator/(long long, Size) noexcept;
1131 extern template STORMBYTE_PUBLIC Size operator/(unsigned long long, Size) noexcept;
1132 extern template STORMBYTE_PUBLIC Size operator/(wchar_t, Size) noexcept;
1133 extern template STORMBYTE_PUBLIC Size operator/(char8_t, Size) noexcept;
1134 extern template STORMBYTE_PUBLIC Size operator/(char16_t, Size) noexcept;
1135 extern template STORMBYTE_PUBLIC Size operator/(char32_t, Size) noexcept;
1136
1137 extern template STORMBYTE_PUBLIC Size operator%(Size, char) noexcept;
1138 extern template STORMBYTE_PUBLIC Size operator%(Size, signed char) noexcept;
1139 extern template STORMBYTE_PUBLIC Size operator%(Size, unsigned char) noexcept;
1140 extern template STORMBYTE_PUBLIC Size operator%(Size, short) noexcept;
1141 extern template STORMBYTE_PUBLIC Size operator%(Size, unsigned short) noexcept;
1142 extern template STORMBYTE_PUBLIC Size operator%(Size, int) noexcept;
1143 extern template STORMBYTE_PUBLIC Size operator%(Size, unsigned int) noexcept;
1144 extern template STORMBYTE_PUBLIC Size operator%(Size, long) noexcept;
1145 extern template STORMBYTE_PUBLIC Size operator%(Size, unsigned long) noexcept;
1146 extern template STORMBYTE_PUBLIC Size operator%(Size, long long) noexcept;
1147 extern template STORMBYTE_PUBLIC Size operator%(Size, unsigned long long) noexcept;
1148 extern template STORMBYTE_PUBLIC Size operator%(Size, wchar_t) noexcept;
1149 extern template STORMBYTE_PUBLIC Size operator%(Size, char8_t) noexcept;
1150 extern template STORMBYTE_PUBLIC Size operator%(Size, char16_t) noexcept;
1151 extern template STORMBYTE_PUBLIC Size operator%(Size, char32_t) noexcept;
1152
1153 extern template STORMBYTE_PUBLIC Size operator%(char, Size) noexcept;
1154 extern template STORMBYTE_PUBLIC Size operator%(signed char, Size) noexcept;
1155 extern template STORMBYTE_PUBLIC Size operator%(unsigned char, Size) noexcept;
1156 extern template STORMBYTE_PUBLIC Size operator%(short, Size) noexcept;
1157 extern template STORMBYTE_PUBLIC Size operator%(unsigned short, Size) noexcept;
1158 extern template STORMBYTE_PUBLIC Size operator%(int, Size) noexcept;
1159 extern template STORMBYTE_PUBLIC Size operator%(unsigned int, Size) noexcept;
1160 extern template STORMBYTE_PUBLIC Size operator%(long, Size) noexcept;
1161 extern template STORMBYTE_PUBLIC Size operator%(unsigned long, Size) noexcept;
1162 extern template STORMBYTE_PUBLIC Size operator%(long long, Size) noexcept;
1163 extern template STORMBYTE_PUBLIC Size operator%(unsigned long long, Size) noexcept;
1164 extern template STORMBYTE_PUBLIC Size operator%(wchar_t, Size) noexcept;
1165 extern template STORMBYTE_PUBLIC Size operator%(char8_t, Size) noexcept;
1166 extern template STORMBYTE_PUBLIC Size operator%(char16_t, Size) noexcept;
1167 extern template STORMBYTE_PUBLIC Size operator%(char32_t, Size) noexcept;
1169}
Owned UTF-8 text composed of StormByte::Safe::CString.
Definition string.hxx:97
Count of abstract units (uint64_t storage).
Definition size.hxx:105
constexpr Size & operator/=(Size other) noexcept
Divide by other.
Definition size.hxx:375
friend constexpr Size operator-(Size lhs, Size rhs) noexcept
Difference.
Definition size.hxx:306
friend constexpr Size operator*(Size lhs, Size rhs) noexcept
Product.
Definition size.hxx:316
constexpr Size operator--(int) noexcept
Postfix decrement.
Definition size.hxx:284
constexpr Size & operator-=(T value) noexcept
Subtract an integer.
Definition size.hxx:479
friend constexpr std::strong_ordering operator<=>(Size lhs, Size rhs) noexcept
Numeric order.
Definition size.hxx:234
constexpr Size & operator%=(T value) noexcept
Remainder with an integer.
Definition size.hxx:515
constexpr Size & operator/=(T value) noexcept
Divide by an integer.
Definition size.hxx:503
constexpr Size & operator+=(T value) noexcept
Add an integer.
Definition size.hxx:467
constexpr Size operator++(int) noexcept
Postfix increment.
Definition size.hxx:265
constexpr Size(T value) noexcept
From an integer count.
Definition size.hxx:118
constexpr Size & operator*=(T value) noexcept
Multiply by an integer.
Definition size.hxx:491
constexpr Size(Size &&other) noexcept=default
Move constructor.
constexpr Size & operator++() noexcept
Prefix increment.
Definition size.hxx:256
friend constexpr Size operator/(Size lhs, Size rhs) noexcept
Quotient.
Definition size.hxx:326
constexpr ~Size() noexcept=default
Destructor.
constexpr Size & operator+=(Size other) noexcept
Add other.
Definition size.hxx:345
constexpr Size & operator%=(Size other) noexcept
Remainder with other.
Definition size.hxx:385
constexpr Size(const Size &other) noexcept=default
Copy constructor.
constexpr Size() noexcept
Zero.
Definition size.hxx:110
constexpr Size & operator--() noexcept
Prefix decrement.
Definition size.hxx:275
constexpr Size & operator-=(Size other) noexcept
Subtract other.
Definition size.hxx:355
friend constexpr Size operator%(Size lhs, Size rhs) noexcept
Remainder.
Definition size.hxx:336
friend constexpr bool operator==(Size lhs, Size rhs) noexcept
Numeric equality.
Definition size.hxx:210
constexpr Size & operator*=(Size other) noexcept
Multiply by other.
Definition size.hxx:365
friend constexpr Size operator+(Size lhs, Size rhs) noexcept
Sum.
Definition size.hxx:296
Same type after stripping cv and references from both sides.
Definition relations.hxx:94
Root namespace of the StormByte suite.
bool operator==(std::span< const std::byte > bytes, const BinaryData &data) noexcept
Equality of a span against a sequence.
Definition binary_data.hxx:777
constexpr ByteSize operator*(ByteSize lhs, T rhs) noexcept
Mixed product.
Definition byte_size.hxx:838
std::ostream & operator<<(std::ostream &stream, ByteSize size)
Writes the IEC human-readable length.
Definition byte_size.hxx:884
constexpr ByteSize operator+(ByteSize lhs, T rhs) noexcept
Mixed sum.
Definition byte_size.hxx:790
constexpr ByteSize operator-(ByteSize lhs, T rhs) noexcept
Mixed difference.
Definition byte_size.hxx:814
std::strong_ordering operator<=>(std::span< const std::byte > bytes, const BinaryData &data) noexcept
Three-way comparison of a span against a sequence.
Definition binary_data.hxx:797
constexpr ByteSize operator%(ByteSize lhs, T rhs) noexcept
Mixed remainder.
Definition byte_size.hxx:874
constexpr ByteSize operator/(ByteSize lhs, T rhs) noexcept
Mixed quotient.
Definition byte_size.hxx:862
Octet count. Defined in byte_size.hxx. Forwarded so Type::Numeral can name it.
STL namespace.
#define STORMBYTE_FORCE_INLINE
Definition platform.h:89
#define STORMBYTE_PUBLIC
Definition visibility.h:52