StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
byte_size.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This is the base for StormByte Suite libraries.
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
45#include <StormByte/size.hxx>
48
49#include <cassert>
50#include <compare>
51#include <cstddef>
52#include <cstdint>
53#include <limits>
54#include <ostream>
55#include <span>
56#include <string>
57#include <type_traits>
58#include <utility>
59
64
69namespace StormByte {
106 public:
110 struct Unit {
111 std::uint64_t bytes;
112
118 constexpr ByteSize operator()(Size count) const noexcept {
119 return ByteSize(Raw{}, Mul(static_cast<std::uint64_t>(static_cast<std::size_t>(count)), bytes));
120 }
121 };
122
123 static constexpr Unit B{1ull};
124 static constexpr Unit KiB{1024ull};
125 static constexpr Unit MiB{1024ull * 1024};
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};
130 static constexpr Unit KB{1000ull};
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};
136
140 constexpr ByteSize() noexcept: m_value(0) {}
141
147 template<Type::Integral T>
148 constexpr ByteSize(T value) noexcept: m_value(FromIntegral(value)) {}
149
154 constexpr explicit ByteSize(Size count) noexcept: m_value(static_cast<std::uint64_t>(static_cast<std::size_t>(count))) {}
155
160 constexpr ByteSize(const ByteSize& other) noexcept = default;
161
166 constexpr ByteSize(ByteSize&& other) noexcept = default;
167
171 constexpr ~ByteSize() noexcept = default;
172
178 constexpr ByteSize& operator=(const ByteSize& other) noexcept = default;
179
185 constexpr ByteSize& operator=(ByteSize&& other) noexcept = default;
186
193 template<Type::Integral T>
194 constexpr ByteSize& operator=(T value) noexcept {
195 m_value = FromIntegral(value);
196 return *this;
197 }
198
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);
206 }
207
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);
218 }
219
224 explicit operator Safe::String() const noexcept;
225
230 explicit operator Safe::WString() const noexcept;
231
236 STORMBYTE_FORCE_INLINE operator std::string() const {
237 // By name. static_cast<Safe::String> is Safe::String(std::string) on GCC,
238 // and that calls this operator again.
239 return operator Safe::String().operator std::string();
240 }
241
248 friend constexpr bool operator==(ByteSize lhs, ByteSize rhs) noexcept {
249 return lhs.m_value == rhs.m_value;
250 }
251
256 template<Type::Integral T>
257 friend constexpr bool operator==(ByteSize lhs, T rhs) noexcept;
258
263 template<Type::Integral T>
264 friend constexpr bool operator==(T lhs, ByteSize rhs) noexcept;
265
272 friend constexpr bool operator==(ByteSize lhs, Size rhs) noexcept {
273 return lhs.m_value == static_cast<std::uint64_t>(static_cast<std::size_t>(rhs));
274 }
275
282 friend constexpr bool operator==(Size lhs, ByteSize rhs) noexcept {
283 return rhs == lhs;
284 }
285
292 friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(ByteSize lhs, ByteSize rhs) noexcept {
293 return lhs.m_value <=> rhs.m_value;
294 }
295
300 template<Type::Integral T>
301 friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(ByteSize lhs, T rhs) noexcept {
302 return lhs <=> ByteSize(rhs);
303 }
304
309 template<Type::Integral T>
310 friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(T lhs, ByteSize rhs) noexcept {
311 return ByteSize(lhs) <=> rhs;
312 }
313
320 friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(ByteSize lhs, Size rhs) noexcept {
321 return lhs.m_value <=> static_cast<std::uint64_t>(static_cast<std::size_t>(rhs));
322 }
323
330 friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(Size lhs, ByteSize rhs) noexcept {
331 return 0 <=> (rhs <=> lhs);
332 }
333
338 constexpr ByteSize& operator++() noexcept {
339 *this += ByteSize(Raw{}, 1);
340 return *this;
341 }
342
347 constexpr ByteSize operator++(int) noexcept {
348 const ByteSize old = *this;
349 ++*this;
350 return old;
351 }
352
357 constexpr ByteSize& operator--() noexcept {
358 *this -= ByteSize(Raw{}, 1);
359 return *this;
360 }
361
366 constexpr ByteSize operator--(int) noexcept {
367 const ByteSize old = *this;
368 --*this;
369 return old;
370 }
371
378 friend constexpr ByteSize operator+(ByteSize lhs, ByteSize rhs) noexcept {
379 return ByteSize(Raw{}, Add(lhs.m_value, rhs.m_value));
380 }
381
388 friend constexpr ByteSize operator-(ByteSize lhs, ByteSize rhs) noexcept {
389 return ByteSize(Raw{}, Sub(lhs.m_value, rhs.m_value));
390 }
391
392 ByteSize operator*(ByteSize) const = delete;
394 ByteSize operator/(ByteSize) const = delete;
396 ByteSize operator%(ByteSize) const = delete;
398
405 friend constexpr ByteSize operator*(ByteSize lhs, Size rhs) noexcept {
406 return ByteSize(Raw{}, Mul(lhs.m_value, static_cast<std::uint64_t>(static_cast<std::size_t>(rhs))));
407 }
408
415 friend constexpr ByteSize operator*(Size lhs, ByteSize rhs) noexcept {
416 return rhs * lhs;
417 }
418
425 friend constexpr ByteSize operator/(ByteSize lhs, Size rhs) noexcept {
426 return ByteSize(Raw{}, Div(lhs.m_value, static_cast<std::uint64_t>(static_cast<std::size_t>(rhs))));
427 }
428
435 friend constexpr ByteSize operator%(ByteSize lhs, Size rhs) noexcept {
436 return ByteSize(Raw{}, Mod(lhs.m_value, static_cast<std::uint64_t>(static_cast<std::size_t>(rhs))));
437 }
438
444 constexpr ByteSize& operator+=(ByteSize other) noexcept {
445 m_value = Add(m_value, other.m_value);
446 return *this;
447 }
448
454 constexpr ByteSize& operator-=(ByteSize other) noexcept {
455 m_value = Sub(m_value, other.m_value);
456 return *this;
457 }
458
464 constexpr ByteSize& operator*=(Size other) noexcept {
465 *this = *this * other;
466 return *this;
467 }
468
474 constexpr ByteSize& operator/=(Size other) noexcept {
475 *this = *this / other;
476 return *this;
477 }
478
484 constexpr ByteSize& operator%=(Size other) noexcept {
485 *this = *this % other;
486 return *this;
487 }
488
493 template<Type::Integral T>
494 friend constexpr ByteSize operator+(ByteSize lhs, T rhs) noexcept;
495
500 template<Type::Integral T>
501 friend constexpr ByteSize operator+(T lhs, ByteSize rhs) noexcept;
502
507 template<Type::Integral T>
508 friend constexpr ByteSize operator-(ByteSize lhs, T rhs) noexcept;
509
514 template<Type::Integral T>
515 friend constexpr ByteSize operator-(T lhs, ByteSize rhs) noexcept;
516
521 template<Type::Integral T>
522 friend constexpr ByteSize operator*(ByteSize lhs, T rhs) noexcept;
523
528 template<Type::Integral T>
529 friend constexpr ByteSize operator*(T lhs, ByteSize rhs) noexcept;
530
535 template<Type::Integral T>
536 friend constexpr ByteSize operator/(ByteSize lhs, T rhs) noexcept;
537
542 template<Type::Integral T>
543 friend constexpr ByteSize operator%(ByteSize lhs, T rhs) noexcept;
544
551 template<Type::Integral T>
552 constexpr ByteSize& operator+=(T value) noexcept {
553 *this = *this + value;
554 return *this;
555 }
556
563 template<Type::Integral T>
564 constexpr ByteSize& operator-=(T value) noexcept {
565 *this = *this - value;
566 return *this;
567 }
568
575 template<Type::Integral T>
576 constexpr ByteSize& operator*=(T value) noexcept {
577 *this = *this * value;
578 return *this;
579 }
580
587 template<Type::Integral T>
588 constexpr ByteSize& operator/=(T value) noexcept {
589 *this = *this / value;
590 return *this;
591 }
592
599 template<Type::Integral T>
600 constexpr ByteSize& operator%=(T value) noexcept {
601 *this = *this % value;
602 return *this;
603 }
604
605 private:
606 std::uint64_t m_value;
607
611 struct Raw {
612 explicit constexpr Raw() noexcept = default;
613 };
614
619 explicit constexpr ByteSize(Raw, std::uint64_t value) noexcept: m_value(value) {}
620
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);
632 }
633
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);
642 return lhs + rhs;
643 }
644
651 static constexpr std::uint64_t Sub(std::uint64_t lhs, std::uint64_t rhs) noexcept {
652 assert(lhs >= rhs);
653 return lhs - rhs;
654 }
655
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);
664 return lhs * rhs;
665 }
666
673 static constexpr std::uint64_t Div(std::uint64_t lhs, std::uint64_t rhs) noexcept {
674 assert(rhs != 0);
675 return lhs / rhs;
676 }
677
684 static constexpr std::uint64_t Mod(std::uint64_t lhs, std::uint64_t rhs) noexcept {
685 assert(rhs != 0);
686 return lhs % rhs;
687 }
688
696 template<Type::Integral T>
697 static constexpr ByteSize MixAdd(std::uint64_t lhs, T rhs) noexcept {
698 if constexpr (Type::Signed<T>) {
699 if (rhs < T{0}) {
700 const auto mag = static_cast<std::uint64_t>(0) - static_cast<std::uint64_t>(rhs);
701 return ByteSize(Raw{}, Sub(lhs, mag));
702 }
703 }
704 return ByteSize(Raw{}, Add(lhs, static_cast<std::uint64_t>(rhs)));
705 }
706
714 template<Type::Integral T>
715 static constexpr ByteSize MixSub(std::uint64_t lhs, T rhs) noexcept {
716 if constexpr (Type::Signed<T>) {
717 if (rhs < T{0}) {
718 const auto mag = static_cast<std::uint64_t>(0) - static_cast<std::uint64_t>(rhs);
719 return ByteSize(Raw{}, Add(lhs, mag));
720 }
721 }
722 return ByteSize(Raw{}, Sub(lhs, static_cast<std::uint64_t>(rhs)));
723 }
724
732 template<Type::Integral T>
733 static constexpr ByteSize MixMul(std::uint64_t lhs, T rhs) noexcept {
734 if constexpr (Type::Signed<T>)
735 assert(rhs >= T{0});
736 return ByteSize(Raw{}, Mul(lhs, static_cast<std::uint64_t>(rhs)));
737 }
738 };
739
747 template<Type::Integral T>
748 constexpr bool operator==(ByteSize lhs, T rhs) noexcept {
749 return lhs == ByteSize(rhs);
750 }
751
759 template<Type::Integral T>
760 constexpr bool operator==(T lhs, ByteSize rhs) noexcept {
761 return ByteSize(lhs) == rhs;
762 }
763
771 template<Type::Integral T>
772 constexpr ByteSize operator+(ByteSize lhs, T rhs) noexcept {
773 return ByteSize::MixAdd(lhs.m_value, rhs);
774 }
775
783 template<Type::Integral T>
784 constexpr ByteSize operator+(T lhs, ByteSize rhs) noexcept {
785 return ByteSize::MixAdd(rhs.m_value, lhs);
786 }
787
795 template<Type::Integral T>
796 constexpr ByteSize operator-(ByteSize lhs, T rhs) noexcept {
797 return ByteSize::MixSub(lhs.m_value, rhs);
798 }
799
807 template<Type::Integral T>
808 constexpr ByteSize operator-(T lhs, ByteSize rhs) noexcept {
809 return ByteSize(lhs) - rhs;
810 }
811
819 template<Type::Integral T>
820 constexpr ByteSize operator*(ByteSize lhs, T rhs) noexcept {
821 return ByteSize::MixMul(lhs.m_value, rhs);
822 }
823
831 template<Type::Integral T>
832 constexpr ByteSize operator*(T lhs, ByteSize rhs) noexcept {
833 return ByteSize::MixMul(rhs.m_value, lhs);
834 }
835
843 template<Type::Integral T>
844 constexpr ByteSize operator/(ByteSize lhs, T rhs) noexcept {
845 return ByteSize(ByteSize::Raw{}, ByteSize::Div(lhs.m_value, ByteSize::FromIntegral(rhs)));
846 }
847
855 template<Type::Integral T>
856 constexpr ByteSize operator%(ByteSize lhs, T rhs) noexcept {
857 return ByteSize(ByteSize::Raw{}, ByteSize::Mod(lhs.m_value, ByteSize::FromIntegral(rhs)));
858 }
859
866 inline std::ostream& operator<<(std::ostream& stream, ByteSize size) {
867 stream << static_cast<std::string>(size);
868 return stream;
869 }
870
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;
887
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;
903
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;
919
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;
935
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;
951
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;
967
968 extern template STORMBYTE_PUBLIC ByteSize::operator char() const noexcept;
969 extern template STORMBYTE_PUBLIC ByteSize::operator signed char() const noexcept;
970 extern template STORMBYTE_PUBLIC ByteSize::operator unsigned char() const noexcept;
971 extern template STORMBYTE_PUBLIC ByteSize::operator short() const noexcept;
972 extern template STORMBYTE_PUBLIC ByteSize::operator unsigned short() const noexcept;
973 extern template STORMBYTE_PUBLIC ByteSize::operator int() const noexcept;
974 extern template STORMBYTE_PUBLIC ByteSize::operator unsigned int() const noexcept;
975 extern template STORMBYTE_PUBLIC ByteSize::operator long() 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;
981
982 extern template STORMBYTE_PUBLIC bool operator==(ByteSize, char) noexcept;
983 extern template STORMBYTE_PUBLIC bool operator==(ByteSize, signed char) noexcept;
984 extern template STORMBYTE_PUBLIC bool operator==(ByteSize, unsigned char) noexcept;
985 extern template STORMBYTE_PUBLIC bool operator==(ByteSize, short) noexcept;
986 extern template STORMBYTE_PUBLIC bool operator==(ByteSize, unsigned short) noexcept;
987 extern template STORMBYTE_PUBLIC bool operator==(ByteSize, int) noexcept;
988 extern template STORMBYTE_PUBLIC bool operator==(ByteSize, unsigned int) noexcept;
989 extern template STORMBYTE_PUBLIC bool operator==(ByteSize, long) 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;
997
998 extern template STORMBYTE_PUBLIC bool operator==(char, ByteSize) 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;
1003 extern template STORMBYTE_PUBLIC bool operator==(int, ByteSize) noexcept;
1004 extern template STORMBYTE_PUBLIC bool operator==(unsigned int, ByteSize) noexcept;
1005 extern template STORMBYTE_PUBLIC bool operator==(long, 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;
1013
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;
1029
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;
1045
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;
1061
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;
1077
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;
1093
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;
1109
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;
1125
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;
1142
1146 inline constexpr ByteSize B{1ull};
1147
1151 inline constexpr ByteSize KiB{1024ull};
1152
1156 inline constexpr ByteSize MiB{1024ull * 1024};
1157
1161 inline constexpr ByteSize GiB{1024ull * 1024 * 1024};
1162
1166 inline constexpr ByteSize TiB{1024ull * 1024 * 1024 * 1024};
1167
1171 inline constexpr ByteSize PiB{1024ull * 1024 * 1024 * 1024 * 1024};
1172
1176 inline constexpr ByteSize EiB{1024ull * 1024 * 1024 * 1024 * 1024 * 1024};
1177
1181 inline constexpr ByteSize KB{1000ull};
1182
1186 inline constexpr ByteSize MB{1000ull * 1000};
1187
1191 inline constexpr ByteSize GB{1000ull * 1000 * 1000};
1192
1196 inline constexpr ByteSize TB{1000ull * 1000 * 1000 * 1000};
1197
1201 inline constexpr ByteSize PB{1000ull * 1000 * 1000 * 1000 * 1000};
1202
1206 inline constexpr ByteSize EB{1000ull * 1000 * 1000 * 1000 * 1000 * 1000};
1207
1208}
1209
1210template<>
1217 STORMBYTE_FORCE_INLINE std::size_t operator()(const StormByte::ByteSize& value) const noexcept {
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)));
1220 }
1221};
1222
1228template<>
1229class std::numeric_limits<StormByte::ByteSize> {
1230 public:
1231 static constexpr bool is_specialized = true;
1232 static constexpr bool is_signed = false;
1233 static constexpr bool is_integer = true;
1234 static constexpr bool is_exact = true;
1235 static constexpr bool has_infinity = false;
1236 static constexpr bool has_quiet_NaN = false;
1237 static constexpr bool has_signaling_NaN = false;
1238 static constexpr std::float_denorm_style has_denorm = std::denorm_absent;
1239 static constexpr bool has_denorm_loss = false;
1240 static constexpr std::float_round_style round_style = std::round_toward_zero;
1241 static constexpr bool is_iec559 = false;
1242 static constexpr bool is_bounded = true;
1243 static constexpr bool is_modulo = false;
1244 static constexpr int digits = 64;
1245 static constexpr int digits10 = 19;
1246 static constexpr int max_digits10 = 0;
1247 static constexpr int radix = 2;
1248 static constexpr int min_exponent = 0;
1249 static constexpr int min_exponent10 = 0;
1250 static constexpr int max_exponent = 0;
1251 static constexpr int max_exponent10 = 0;
1252 static constexpr bool traps = false;
1253 static constexpr bool tinyness_before = false;
1254
1256 static constexpr StormByte::ByteSize min() noexcept { return StormByte::ByteSize{0}; }
1258 static constexpr StormByte::ByteSize lowest() noexcept { return StormByte::ByteSize{0}; }
1260 static constexpr StormByte::ByteSize max() noexcept { return StormByte::ByteSize{std::numeric_limits<std::uint64_t>::max()}; }
1262 static constexpr StormByte::ByteSize epsilon() noexcept { return StormByte::ByteSize{0}; }
1264 static constexpr StormByte::ByteSize round_error() noexcept { return StormByte::ByteSize{0}; }
1266 static constexpr StormByte::ByteSize infinity() noexcept { return StormByte::ByteSize{0}; }
1268 static constexpr StormByte::ByteSize quiet_NaN() noexcept { return StormByte::ByteSize{0}; }
1270 static constexpr StormByte::ByteSize signaling_NaN() noexcept { return StormByte::ByteSize{0}; }
1272 static constexpr StormByte::ByteSize denorm_min() noexcept { return StormByte::ByteSize{0}; }
1273};
1274
1275template<>
1276struct std::hash<StormByte::ByteSize> {
1282 std::size_t operator()(const StormByte::ByteSize& value) const noexcept {
1284 }
1285};
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.
STL namespace.
#define STORMBYTE_FORCE_INLINE
Definition platform.h:134
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