119 return ByteSize(Raw{}, Mul(
static_cast<std::uint64_t
>(
static_cast<std::size_t
>(count)),
bytes));
126 static constexpr Unit GiB{1024ull * 1024 * 1024};
127 static constexpr Unit TiB{1024ull * 1024 * 1024 * 1024};
128 static constexpr Unit PiB{1024ull * 1024 * 1024 * 1024 * 1024};
129 static constexpr Unit EiB{1024ull * 1024 * 1024 * 1024 * 1024 * 1024};
131 static constexpr Unit MB{1000ull * 1000};
132 static constexpr Unit GB{1000ull * 1000 * 1000};
133 static constexpr Unit TB{1000ull * 1000 * 1000 * 1000};
134 static constexpr Unit PB{1000ull * 1000 * 1000 * 1000 * 1000};
135 static constexpr Unit EB{1000ull * 1000 * 1000 * 1000 * 1000 * 1000};
147 template<Type::Integral T>
148 constexpr ByteSize(T value)
noexcept: m_value(FromIntegral(value)) {}
154 constexpr explicit ByteSize(
Size count)
noexcept: m_value(
static_cast<std::uint64_t
>(
static_cast<std::size_t
>(count))) {}
193 template<
Type::Integral T>
195 m_value = FromIntegral(value);
203 constexpr operator std::size_t() const noexcept {
204 constexpr auto max =
static_cast<std::uint64_t
>(std::numeric_limits<std::size_t>::max());
205 return static_cast<std::size_t
>(m_value > max ? max : m_value);
213 template<Type::Integral T>
215 constexpr explicit operator T()
const noexcept {
216 constexpr auto max =
static_cast<std::uint64_t
>(std::numeric_limits<T>::max());
217 return static_cast<T
>(m_value > max ? max : m_value);
249 return lhs.m_value == rhs.m_value;
256 template<Type::Integral T>
263 template<Type::Integral T>
273 return lhs.m_value ==
static_cast<std::uint64_t
>(
static_cast<std::size_t
>(rhs));
293 return lhs.m_value <=> rhs.m_value;
300 template<Type::Integral T>
309 template<Type::Integral T>
321 return lhs.m_value <=>
static_cast<std::uint64_t
>(
static_cast<std::size_t
>(rhs));
331 return 0 <=> (rhs <=> lhs);
379 return ByteSize(Raw{}, Add(lhs.m_value, rhs.m_value));
389 return ByteSize(Raw{}, Sub(lhs.m_value, rhs.m_value));
406 return ByteSize(Raw{}, Mul(lhs.m_value,
static_cast<std::uint64_t
>(
static_cast<std::size_t
>(rhs))));
426 return ByteSize(Raw{}, Div(lhs.m_value,
static_cast<std::uint64_t
>(
static_cast<std::size_t
>(rhs))));
436 return ByteSize(Raw{}, Mod(lhs.m_value,
static_cast<std::uint64_t
>(
static_cast<std::size_t
>(rhs))));
445 m_value = Add(m_value, other.m_value);
455 m_value = Sub(m_value, other.m_value);
465 *
this = *
this * other;
475 *
this = *
this / other;
485 *
this = *
this % other;
493 template<Type::Integral T>
500 template<Type::Integral T>
507 template<Type::Integral T>
514 template<Type::Integral T>
521 template<Type::Integral T>
528 template<Type::Integral T>
535 template<Type::Integral T>
542 template<Type::Integral T>
551 template<Type::Integral T>
553 *
this = *
this + value;
563 template<Type::Integral T>
565 *
this = *
this - value;
575 template<Type::Integral T>
577 *
this = *
this * value;
587 template<Type::Integral T>
589 *
this = *
this / value;
599 template<Type::Integral T>
601 *
this = *
this % value;
606 std::uint64_t m_value;
612 explicit constexpr Raw() noexcept = default;
619 explicit constexpr
ByteSize(Raw,
std::uint64_t value) noexcept: m_value(value) {}
627 template<Type::Integral T>
628 static constexpr std::uint64_t FromIntegral(T value)
noexcept {
629 if constexpr (Type::Signed<T>)
630 assert(value >= T{0});
631 return static_cast<std::uint64_t
>(value);
640 static constexpr std::uint64_t Add(std::uint64_t lhs, std::uint64_t rhs)
noexcept {
641 assert(lhs <= std::numeric_limits<std::uint64_t>::max() - rhs);
651 static constexpr std::uint64_t Sub(std::uint64_t lhs, std::uint64_t rhs)
noexcept {
662 static constexpr std::uint64_t Mul(std::uint64_t lhs, std::uint64_t rhs)
noexcept {
663 assert(rhs == 0 || lhs <= std::numeric_limits<std::uint64_t>::max() / rhs);
673 static constexpr std::uint64_t Div(std::uint64_t lhs, std::uint64_t rhs)
noexcept {
684 static constexpr std::uint64_t Mod(std::uint64_t lhs, std::uint64_t rhs)
noexcept {
696 template<Type::Integral T>
697 static constexpr ByteSize MixAdd(std::uint64_t lhs, T rhs)
noexcept {
698 if constexpr (Type::Signed<T>) {
700 const auto mag =
static_cast<std::uint64_t
>(0) -
static_cast<std::uint64_t
>(rhs);
701 return ByteSize(Raw{}, Sub(lhs, mag));
704 return ByteSize(Raw{}, Add(lhs,
static_cast<std::uint64_t
>(rhs)));
714 template<Type::Integral T>
715 static constexpr ByteSize MixSub(std::uint64_t lhs, T rhs)
noexcept {
716 if constexpr (Type::Signed<T>) {
718 const auto mag =
static_cast<std::uint64_t
>(0) -
static_cast<std::uint64_t
>(rhs);
719 return ByteSize(Raw{}, Add(lhs, mag));
722 return ByteSize(Raw{}, Sub(lhs,
static_cast<std::uint64_t
>(rhs)));
732 template<Type::Integral T>
733 static constexpr ByteSize MixMul(std::uint64_t lhs, T rhs)
noexcept {
734 if constexpr (Type::Signed<T>)
736 return ByteSize(Raw{}, Mul(lhs,
static_cast<std::uint64_t
>(rhs)));
747 template<Type::Integral T>
759 template<Type::Integral T>
771 template<Type::Integral T>
773 return ByteSize::MixAdd(lhs.m_value, rhs);
783 template<Type::Integral T>
785 return ByteSize::MixAdd(rhs.m_value, lhs);
795 template<Type::Integral T>
797 return ByteSize::MixSub(lhs.m_value, rhs);
807 template<Type::Integral T>
819 template<Type::Integral T>
821 return ByteSize::MixMul(lhs.m_value, rhs);
831 template<Type::Integral T>
833 return ByteSize::MixMul(rhs.m_value, lhs);
843 template<Type::Integral T>
845 return ByteSize(ByteSize::Raw{}, ByteSize::Div(lhs.m_value, ByteSize::FromIntegral(rhs)));
855 template<Type::Integral T>
857 return ByteSize(ByteSize::Raw{}, ByteSize::Mod(lhs.m_value, ByteSize::FromIntegral(rhs)));
867 stream << static_cast<std::string>(size);
872 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
char)
noexcept;
873 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
signed char)
noexcept;
874 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
unsigned char)
noexcept;
875 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
short)
noexcept;
876 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
unsigned short)
noexcept;
877 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
int)
noexcept;
878 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
unsigned int)
noexcept;
879 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
long)
noexcept;
880 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
unsigned long)
noexcept;
881 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
long long)
noexcept;
882 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
unsigned long long)
noexcept;
883 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
wchar_t)
noexcept;
884 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
char8_t)
noexcept;
885 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
char16_t)
noexcept;
886 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator=(
char32_t)
noexcept;
888 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
char)
noexcept;
889 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
signed char)
noexcept;
890 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
unsigned char)
noexcept;
891 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
short)
noexcept;
892 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
unsigned short)
noexcept;
893 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
int)
noexcept;
894 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
unsigned int)
noexcept;
895 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
long)
noexcept;
896 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
unsigned long)
noexcept;
897 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
long long)
noexcept;
898 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
unsigned long long)
noexcept;
899 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
wchar_t)
noexcept;
900 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
char8_t)
noexcept;
901 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
char16_t)
noexcept;
902 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator+=(
char32_t)
noexcept;
904 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
char)
noexcept;
905 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
signed char)
noexcept;
906 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
unsigned char)
noexcept;
907 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
short)
noexcept;
908 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
unsigned short)
noexcept;
909 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
int)
noexcept;
910 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
unsigned int)
noexcept;
911 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
long)
noexcept;
912 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
unsigned long)
noexcept;
913 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
long long)
noexcept;
914 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
unsigned long long)
noexcept;
915 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
wchar_t)
noexcept;
916 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
char8_t)
noexcept;
917 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
char16_t)
noexcept;
918 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator-=(
char32_t)
noexcept;
920 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
char)
noexcept;
921 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
signed char)
noexcept;
922 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
unsigned char)
noexcept;
923 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
short)
noexcept;
924 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
unsigned short)
noexcept;
925 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
int)
noexcept;
926 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
unsigned int)
noexcept;
927 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
long)
noexcept;
928 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
unsigned long)
noexcept;
929 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
long long)
noexcept;
930 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
unsigned long long)
noexcept;
931 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
wchar_t)
noexcept;
932 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
char8_t)
noexcept;
933 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
char16_t)
noexcept;
934 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator*=(
char32_t)
noexcept;
936 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
char)
noexcept;
937 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
signed char)
noexcept;
938 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
unsigned char)
noexcept;
939 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
short)
noexcept;
940 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
unsigned short)
noexcept;
941 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
int)
noexcept;
942 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
unsigned int)
noexcept;
943 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
long)
noexcept;
944 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
unsigned long)
noexcept;
945 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
long long)
noexcept;
946 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
unsigned long long)
noexcept;
947 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
wchar_t)
noexcept;
948 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
char8_t)
noexcept;
949 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
char16_t)
noexcept;
950 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator/=(
char32_t)
noexcept;
952 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
char)
noexcept;
953 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
signed char)
noexcept;
954 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
unsigned char)
noexcept;
955 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
short)
noexcept;
956 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
unsigned short)
noexcept;
957 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
int)
noexcept;
958 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
unsigned int)
noexcept;
959 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
long)
noexcept;
960 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
unsigned long)
noexcept;
961 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
long long)
noexcept;
962 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
unsigned long long)
noexcept;
963 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
wchar_t)
noexcept;
964 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
char8_t)
noexcept;
965 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
char16_t)
noexcept;
966 extern template STORMBYTE_PUBLIC ByteSize& ByteSize::operator%=(
char32_t)
noexcept;
969 extern template
STORMBYTE_PUBLIC ByteSize::operator
signed char() const noexcept;
970 extern template
STORMBYTE_PUBLIC ByteSize::operator
unsigned char() const noexcept;
972 extern template
STORMBYTE_PUBLIC ByteSize::operator
unsigned short() const noexcept;
974 extern template
STORMBYTE_PUBLIC ByteSize::operator
unsigned int() const noexcept;
976 extern template
STORMBYTE_PUBLIC ByteSize::operator
long long() const noexcept;
977 extern template
STORMBYTE_PUBLIC ByteSize::operator
wchar_t() const noexcept;
978 extern template
STORMBYTE_PUBLIC ByteSize::operator
char8_t() const noexcept;
979 extern template
STORMBYTE_PUBLIC ByteSize::operator
char16_t() const noexcept;
980 extern template
STORMBYTE_PUBLIC ByteSize::operator
char32_t() const noexcept;
983 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
signed char) noexcept;
984 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
unsigned char) noexcept;
986 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
unsigned short) noexcept;
988 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
unsigned int) noexcept;
990 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
unsigned long) noexcept;
991 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
long long) noexcept;
992 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
unsigned long long) noexcept;
993 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
wchar_t) noexcept;
994 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
char8_t) noexcept;
995 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
char16_t) noexcept;
996 extern template
STORMBYTE_PUBLIC bool operator==(ByteSize,
char32_t) noexcept;
999 extern template
STORMBYTE_PUBLIC bool operator==(
signed char, ByteSize) noexcept;
1000 extern template
STORMBYTE_PUBLIC bool operator==(
unsigned char, ByteSize) noexcept;
1001 extern template
STORMBYTE_PUBLIC bool operator==(
short, ByteSize) noexcept;
1002 extern template
STORMBYTE_PUBLIC bool operator==(
unsigned short, ByteSize) noexcept;
1004 extern template
STORMBYTE_PUBLIC bool operator==(
unsigned int, ByteSize) noexcept;
1006 extern template
STORMBYTE_PUBLIC bool operator==(
unsigned long, ByteSize) noexcept;
1007 extern template
STORMBYTE_PUBLIC bool operator==(
long long, ByteSize) noexcept;
1008 extern template
STORMBYTE_PUBLIC bool operator==(
unsigned long long, ByteSize) noexcept;
1009 extern template
STORMBYTE_PUBLIC bool operator==(
wchar_t, ByteSize) noexcept;
1010 extern template
STORMBYTE_PUBLIC bool operator==(
char8_t, ByteSize) noexcept;
1011 extern template
STORMBYTE_PUBLIC bool operator==(
char16_t, ByteSize) noexcept;
1012 extern template
STORMBYTE_PUBLIC bool operator==(
char32_t, ByteSize) noexcept;
1014 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
char) noexcept;
1015 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
signed char) noexcept;
1016 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
unsigned char) noexcept;
1017 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
short) noexcept;
1018 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
unsigned short) noexcept;
1019 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
int) noexcept;
1020 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
unsigned int) noexcept;
1021 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
long) noexcept;
1022 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
unsigned long) noexcept;
1023 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
long long) noexcept;
1024 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
unsigned long long) noexcept;
1025 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
wchar_t) noexcept;
1026 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
char8_t) noexcept;
1027 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
char16_t) noexcept;
1028 extern template
STORMBYTE_PUBLIC ByteSize operator+(ByteSize,
char32_t) noexcept;
1030 extern template
STORMBYTE_PUBLIC ByteSize operator+(
char, ByteSize) noexcept;
1031 extern template
STORMBYTE_PUBLIC ByteSize operator+(
signed char, ByteSize) noexcept;
1032 extern template
STORMBYTE_PUBLIC ByteSize operator+(
unsigned char, ByteSize) noexcept;
1033 extern template
STORMBYTE_PUBLIC ByteSize operator+(
short, ByteSize) noexcept;
1034 extern template
STORMBYTE_PUBLIC ByteSize operator+(
unsigned short, ByteSize) noexcept;
1035 extern template
STORMBYTE_PUBLIC ByteSize operator+(
int, ByteSize) noexcept;
1036 extern template
STORMBYTE_PUBLIC ByteSize operator+(
unsigned int, ByteSize) noexcept;
1037 extern template
STORMBYTE_PUBLIC ByteSize operator+(
long, ByteSize) noexcept;
1038 extern template
STORMBYTE_PUBLIC ByteSize operator+(
unsigned long, ByteSize) noexcept;
1039 extern template
STORMBYTE_PUBLIC ByteSize operator+(
long long, ByteSize) noexcept;
1040 extern template
STORMBYTE_PUBLIC ByteSize operator+(
unsigned long long, ByteSize) noexcept;
1041 extern template
STORMBYTE_PUBLIC ByteSize operator+(
wchar_t, ByteSize) noexcept;
1042 extern template
STORMBYTE_PUBLIC ByteSize operator+(
char8_t, ByteSize) noexcept;
1043 extern template
STORMBYTE_PUBLIC ByteSize operator+(
char16_t, ByteSize) noexcept;
1044 extern template
STORMBYTE_PUBLIC ByteSize operator+(
char32_t, ByteSize) noexcept;
1046 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
char) noexcept;
1047 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
signed char) noexcept;
1048 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
unsigned char) noexcept;
1049 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
short) noexcept;
1050 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
unsigned short) noexcept;
1051 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
int) noexcept;
1052 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
unsigned int) noexcept;
1053 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
long) noexcept;
1054 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
unsigned long) noexcept;
1055 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
long long) noexcept;
1056 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
unsigned long long) noexcept;
1057 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
wchar_t) noexcept;
1058 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
char8_t) noexcept;
1059 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
char16_t) noexcept;
1060 extern template
STORMBYTE_PUBLIC ByteSize operator-(ByteSize,
char32_t) noexcept;
1062 extern template
STORMBYTE_PUBLIC ByteSize operator-(
char, ByteSize) noexcept;
1063 extern template
STORMBYTE_PUBLIC ByteSize operator-(
signed char, ByteSize) noexcept;
1064 extern template
STORMBYTE_PUBLIC ByteSize operator-(
unsigned char, ByteSize) noexcept;
1065 extern template
STORMBYTE_PUBLIC ByteSize operator-(
short, ByteSize) noexcept;
1066 extern template
STORMBYTE_PUBLIC ByteSize operator-(
unsigned short, ByteSize) noexcept;
1067 extern template
STORMBYTE_PUBLIC ByteSize operator-(
int, ByteSize) noexcept;
1068 extern template
STORMBYTE_PUBLIC ByteSize operator-(
unsigned int, ByteSize) noexcept;
1069 extern template
STORMBYTE_PUBLIC ByteSize operator-(
long, ByteSize) noexcept;
1070 extern template
STORMBYTE_PUBLIC ByteSize operator-(
unsigned long, ByteSize) noexcept;
1071 extern template
STORMBYTE_PUBLIC ByteSize operator-(
long long, ByteSize) noexcept;
1072 extern template
STORMBYTE_PUBLIC ByteSize operator-(
unsigned long long, ByteSize) noexcept;
1073 extern template
STORMBYTE_PUBLIC ByteSize operator-(
wchar_t, ByteSize) noexcept;
1074 extern template
STORMBYTE_PUBLIC ByteSize operator-(
char8_t, ByteSize) noexcept;
1075 extern template
STORMBYTE_PUBLIC ByteSize operator-(
char16_t, ByteSize) noexcept;
1076 extern template
STORMBYTE_PUBLIC ByteSize operator-(
char32_t, ByteSize) noexcept;
1078 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
char) noexcept;
1079 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
signed char) noexcept;
1080 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
unsigned char) noexcept;
1081 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
short) noexcept;
1082 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
unsigned short) noexcept;
1083 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
int) noexcept;
1084 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
unsigned int) noexcept;
1085 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
long) noexcept;
1086 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
unsigned long) noexcept;
1087 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
long long) noexcept;
1088 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
unsigned long long) noexcept;
1089 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
wchar_t) noexcept;
1090 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
char8_t) noexcept;
1091 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
char16_t) noexcept;
1092 extern template
STORMBYTE_PUBLIC ByteSize operator*(ByteSize,
char32_t) noexcept;
1094 extern template
STORMBYTE_PUBLIC ByteSize operator*(
char, ByteSize) noexcept;
1095 extern template
STORMBYTE_PUBLIC ByteSize operator*(
signed char, ByteSize) noexcept;
1096 extern template
STORMBYTE_PUBLIC ByteSize operator*(
unsigned char, ByteSize) noexcept;
1097 extern template
STORMBYTE_PUBLIC ByteSize operator*(
short, ByteSize) noexcept;
1098 extern template
STORMBYTE_PUBLIC ByteSize operator*(
unsigned short, ByteSize) noexcept;
1099 extern template
STORMBYTE_PUBLIC ByteSize operator*(
int, ByteSize) noexcept;
1100 extern template
STORMBYTE_PUBLIC ByteSize operator*(
unsigned int, ByteSize) noexcept;
1101 extern template
STORMBYTE_PUBLIC ByteSize operator*(
long, ByteSize) noexcept;
1102 extern template
STORMBYTE_PUBLIC ByteSize operator*(
unsigned long, ByteSize) noexcept;
1103 extern template
STORMBYTE_PUBLIC ByteSize operator*(
long long, ByteSize) noexcept;
1104 extern template
STORMBYTE_PUBLIC ByteSize operator*(
unsigned long long, ByteSize) noexcept;
1105 extern template
STORMBYTE_PUBLIC ByteSize operator*(
wchar_t, ByteSize) noexcept;
1106 extern template
STORMBYTE_PUBLIC ByteSize operator*(
char8_t, ByteSize) noexcept;
1107 extern template
STORMBYTE_PUBLIC ByteSize operator*(
char16_t, ByteSize) noexcept;
1108 extern template
STORMBYTE_PUBLIC ByteSize operator*(
char32_t, ByteSize) noexcept;
1110 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
char) noexcept;
1111 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
signed char) noexcept;
1112 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
unsigned char) noexcept;
1113 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
short) noexcept;
1114 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
unsigned short) noexcept;
1115 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
int) noexcept;
1116 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
unsigned int) noexcept;
1117 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
long) noexcept;
1118 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
unsigned long) noexcept;
1119 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
long long) noexcept;
1120 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
unsigned long long) noexcept;
1121 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
wchar_t) noexcept;
1122 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
char8_t) noexcept;
1123 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
char16_t) noexcept;
1124 extern template
STORMBYTE_PUBLIC ByteSize operator/(ByteSize,
char32_t) noexcept;
1126 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
char) noexcept;
1127 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
signed char) noexcept;
1128 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
unsigned char) noexcept;
1129 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
short) noexcept;
1130 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
unsigned short) noexcept;
1131 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
int) noexcept;
1132 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
unsigned int) noexcept;
1133 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
long) noexcept;
1134 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
unsigned long) noexcept;
1135 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
long long) noexcept;
1136 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
unsigned long long) noexcept;
1137 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
wchar_t) noexcept;
1138 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
char8_t) noexcept;
1139 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
char16_t) noexcept;
1140 extern template
STORMBYTE_PUBLIC ByteSize operator%(ByteSize,
char32_t) noexcept;
1176 inline constexpr ByteSize EiB{1024ull * 1024 * 1024 * 1024 * 1024 * 1024};
1201 inline constexpr ByteSize PB{1000ull * 1000 * 1000 * 1000 * 1000};
1206 inline constexpr ByteSize EB{1000ull * 1000 * 1000 * 1000 * 1000 * 1000};
1218 const auto widened =
static_cast<std::uint64_t
>(
static_cast<std::size_t
>(value));
1219 return Safe::HashBytes(std::as_bytes(std::span<const std::uint64_t>(&widened, 1)));
1229class std::numeric_limits<StormByte::ByteSize> {
1238 static constexpr std::float_denorm_style
has_denorm = std::denorm_absent;
1240 static constexpr std::float_round_style
round_style = std::round_toward_zero;
1276struct std::hash<StormByte::ByteSize> {
Count of octets (uint64_t storage).
Definition byte_size.hxx:105
ByteSize operator%(ByteSize) const =delete
constexpr ByteSize & operator/=(T value) noexcept
Divide by an integer.
Definition byte_size.hxx:588
constexpr ByteSize operator++(int) noexcept
Postfix increment.
Definition byte_size.hxx:347
friend constexpr bool operator==(ByteSize lhs, Size rhs) noexcept
Mixed equality with Size.
Definition byte_size.hxx:272
friend constexpr ByteSize operator-(ByteSize lhs, ByteSize rhs) noexcept
Difference of lengths.
Definition byte_size.hxx:388
ByteSize operator*(ByteSize) const =delete
constexpr ByteSize & operator+=(ByteSize other) noexcept
Add other octets.
Definition byte_size.hxx:444
friend constexpr bool operator==(Size lhs, ByteSize rhs) noexcept
Mixed equality with Size.
Definition byte_size.hxx:282
ByteSize & operator%=(ByteSize)=delete
static constexpr Unit PiB
2^50 octets
Definition byte_size.hxx:128
static constexpr Unit GB
10^9 octets
Definition byte_size.hxx:132
operator Safe::WString() const noexcept
IEC human-readable wide text owned by Base.
constexpr ByteSize(T value) noexcept
From an integer octet count.
Definition byte_size.hxx:148
static constexpr Unit PB
10^15 octets
Definition byte_size.hxx:134
static constexpr Unit MB
10^6 octets
Definition byte_size.hxx:131
constexpr ByteSize & operator--() noexcept
Prefix decrement.
Definition byte_size.hxx:357
friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(ByteSize lhs, T rhs) noexcept
Mixed order with an integer.
Definition byte_size.hxx:301
friend constexpr ByteSize operator%(ByteSize lhs, Size rhs) noexcept
Remainder with a unit count.
Definition byte_size.hxx:435
static constexpr Unit TB
10^12 octets
Definition byte_size.hxx:133
constexpr ByteSize operator--(int) noexcept
Postfix decrement.
Definition byte_size.hxx:366
constexpr ByteSize & operator%=(T value) noexcept
Remainder with an integer.
Definition byte_size.hxx:600
friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(T lhs, ByteSize rhs) noexcept
Mixed order with an integer.
Definition byte_size.hxx:310
friend constexpr ByteSize operator+(ByteSize lhs, ByteSize rhs) noexcept
Sum of lengths.
Definition byte_size.hxx:378
constexpr ByteSize & operator*=(Size other) noexcept
Scale by a unit count.
Definition byte_size.hxx:464
static constexpr Unit GiB
2^30 octets
Definition byte_size.hxx:126
static constexpr Unit EB
10^18 octets
Definition byte_size.hxx:135
ByteSize operator/(ByteSize) const =delete
constexpr ByteSize & operator-=(ByteSize other) noexcept
Subtract other octets.
Definition byte_size.hxx:454
constexpr ByteSize & operator*=(T value) noexcept
Scale by an integer.
Definition byte_size.hxx:576
friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(ByteSize lhs, ByteSize rhs) noexcept
Numeric order.
Definition byte_size.hxx:292
friend constexpr bool operator==(ByteSize lhs, ByteSize rhs) noexcept
Numeric equality.
Definition byte_size.hxx:248
static constexpr Unit EiB
2^60 octets
Definition byte_size.hxx:129
ByteSize & operator/=(ByteSize)=delete
constexpr ByteSize & operator/=(Size other) noexcept
Divide by a unit count.
Definition byte_size.hxx:474
constexpr ByteSize & operator-=(T value) noexcept
Subtract an integer octet count.
Definition byte_size.hxx:564
constexpr ByteSize(Size count) noexcept
From an abstract unit count interpreted as octets.
Definition byte_size.hxx:154
friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(ByteSize lhs, Size rhs) noexcept
Mixed order with Size.
Definition byte_size.hxx:320
static constexpr Unit KB
10^3 octets
Definition byte_size.hxx:130
static constexpr Unit B
2^0 octets
Definition byte_size.hxx:123
constexpr ByteSize & operator%=(Size other) noexcept
Remainder with a unit count.
Definition byte_size.hxx:484
constexpr ByteSize(ByteSize &&other) noexcept=default
Move constructor.
friend constexpr ByteSize operator*(Size lhs, ByteSize rhs) noexcept
Scale by a unit count.
Definition byte_size.hxx:415
static constexpr Unit MiB
2^20 octets
Definition byte_size.hxx:125
friend constexpr ByteSize operator/(ByteSize lhs, Size rhs) noexcept
Divide by a unit count.
Definition byte_size.hxx:425
constexpr ~ByteSize() noexcept=default
Destructor.
constexpr ByteSize & operator++() noexcept
Prefix increment.
Definition byte_size.hxx:338
static constexpr Unit KiB
2^10 octets
Definition byte_size.hxx:124
friend constexpr ByteSize operator*(ByteSize lhs, Size rhs) noexcept
Scale by a unit count.
Definition byte_size.hxx:405
friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(Size lhs, ByteSize rhs) noexcept
Mixed order with Size.
Definition byte_size.hxx:330
static constexpr Unit TiB
2^40 octets
Definition byte_size.hxx:127
ByteSize & operator*=(ByteSize)=delete
constexpr ByteSize() noexcept
Zero octets.
Definition byte_size.hxx:140
constexpr ByteSize & operator+=(T value) noexcept
Add an integer octet count.
Definition byte_size.hxx:552
constexpr ByteSize(const ByteSize &other) noexcept=default
Copy constructor.
Owned UTF-8 text.
Definition string.hxx:113
Count of abstract units (uint64_t storage).
Definition size.hxx:107
static constexpr StormByte::ByteSize min() noexcept
Zero octets.
Definition byte_size.hxx:1256
static constexpr int max_exponent10
Definition byte_size.hxx:1251
static constexpr bool tinyness_before
Definition byte_size.hxx:1253
static constexpr std::float_round_style round_style
Definition byte_size.hxx:1240
static constexpr bool is_specialized
Definition byte_size.hxx:1231
static constexpr std::float_denorm_style has_denorm
Definition byte_size.hxx:1238
static constexpr StormByte::ByteSize lowest() noexcept
Zero octets.
Definition byte_size.hxx:1258
static constexpr StormByte::ByteSize epsilon() noexcept
Not meaningful for an integer.
Definition byte_size.hxx:1262
static constexpr StormByte::ByteSize quiet_NaN() noexcept
Not meaningful.
Definition byte_size.hxx:1268
static constexpr bool traps
Definition byte_size.hxx:1252
static constexpr int radix
Definition byte_size.hxx:1247
static constexpr StormByte::ByteSize round_error() noexcept
Not meaningful for an integer.
Definition byte_size.hxx:1264
static constexpr int digits
Definition byte_size.hxx:1244
static constexpr int max_exponent
Definition byte_size.hxx:1250
static constexpr bool has_quiet_NaN
Definition byte_size.hxx:1236
static constexpr bool is_bounded
Definition byte_size.hxx:1242
static constexpr StormByte::ByteSize infinity() noexcept
Not meaningful.
Definition byte_size.hxx:1266
static constexpr StormByte::ByteSize signaling_NaN() noexcept
Not meaningful.
Definition byte_size.hxx:1270
static constexpr bool is_iec559
Definition byte_size.hxx:1241
static constexpr StormByte::ByteSize max() noexcept
2^64 - 1 octets.
Definition byte_size.hxx:1260
static constexpr int min_exponent
Definition byte_size.hxx:1248
static constexpr int max_digits10
Definition byte_size.hxx:1246
static constexpr bool has_signaling_NaN
Definition byte_size.hxx:1237
static constexpr int min_exponent10
Definition byte_size.hxx:1249
static constexpr bool is_modulo
Definition byte_size.hxx:1243
static constexpr bool is_signed
Definition byte_size.hxx:1232
static constexpr int digits10
Definition byte_size.hxx:1245
static constexpr bool is_exact
Definition byte_size.hxx:1234
static constexpr bool is_integer
Definition byte_size.hxx:1233
static constexpr StormByte::ByteSize denorm_min() noexcept
Not meaningful.
Definition byte_size.hxx:1272
static constexpr bool has_infinity
Definition byte_size.hxx:1235
static constexpr bool has_denorm_loss
Definition byte_size.hxx:1239
Same type after stripping cv and references from both sides.
Definition relations.hxx:139
Owned values that cross a DLL without the caller's CRT.
STORMBYTE_FORCE_INLINE std::size_t HashBytes(std::span< const std::byte > bytes) noexcept
Mix a byte range with FNV-1a.
Definition hash.hxx:66
Root namespace of the StormByte suite.
constexpr ByteSize GB
10^9 octets.
Definition byte_size.hxx:1191
constexpr bool operator==(ByteSize lhs, T rhs) noexcept
Mixed equality.
Definition byte_size.hxx:748
constexpr ByteSize PB
10^15 octets.
Definition byte_size.hxx:1201
constexpr ByteSize EB
10^18 octets.
Definition byte_size.hxx:1206
constexpr ByteSize KB
10^3 octets.
Definition byte_size.hxx:1181
constexpr ByteSize operator%(ByteSize lhs, T rhs) noexcept
Mixed remainder.
Definition byte_size.hxx:856
std::ostream & operator<<(std::ostream &stream, ByteSize size)
Writes the IEC human-readable length.
Definition byte_size.hxx:866
constexpr ByteSize MB
10^6 octets.
Definition byte_size.hxx:1186
constexpr ByteSize operator+(ByteSize lhs, T rhs) noexcept
Mixed sum.
Definition byte_size.hxx:772
constexpr ByteSize KiB
2^10 octets.
Definition byte_size.hxx:1151
constexpr ByteSize GiB
2^30 octets.
Definition byte_size.hxx:1161
constexpr ByteSize operator*(ByteSize lhs, T rhs) noexcept
Mixed product.
Definition byte_size.hxx:820
constexpr ByteSize PiB
2^50 octets.
Definition byte_size.hxx:1171
constexpr ByteSize TB
10^12 octets.
Definition byte_size.hxx:1196
constexpr ByteSize TiB
2^40 octets.
Definition byte_size.hxx:1166
constexpr ByteSize operator/(ByteSize lhs, T rhs) noexcept
Mixed quotient.
Definition byte_size.hxx:844
constexpr ByteSize MiB
2^20 octets.
Definition byte_size.hxx:1156
constexpr ByteSize B
One octet.
Definition byte_size.hxx:1146
constexpr ByteSize EiB
2^60 octets.
Definition byte_size.hxx:1176
constexpr ByteSize operator-(ByteSize lhs, T rhs) noexcept
Mixed difference.
Definition byte_size.hxx:796
Octet count. Defined in byte_size.hxx. Forwarded so Type::Numeral can name it.
Host-width-stable count (uint64_t), implicit only to std::size_t.
One-octet scale used by the named factories.
Definition byte_size.hxx:110
std::uint64_t bytes
Octets in one unit.
Definition byte_size.hxx:111
constexpr ByteSize operator()(Size count) const noexcept
Scale count units into a ByteSize.
Definition byte_size.hxx:118
STORMBYTE_FORCE_INLINE std::size_t operator()(const StormByte::ByteSize &value) const noexcept
Hashes value.
Definition byte_size.hxx:1217
Cross-module hash.
Definition hash.hxx:95
std::size_t operator()(const StormByte::ByteSize &value) const noexcept
Hashes value.
Definition byte_size.hxx:1282
#define STORMBYTE_PUBLIC
Definition visibility.h:52