Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Loading...
Searching...
No Matches
Memory.hpp
Go to the documentation of this file.
1// Copyright © 2020-2024 Alexandre Coderre-Chabot
2//
3// This file is part of Physical Quantities (PhQ), a C++ library of physical quantities, physical
4// models, and units of measure for scientific computing.
5//
6// Physical Quantities is hosted at:
7// https://github.com/acodcha/phq
8//
9// Physical Quantities is licensed under the MIT License:
10// https://mit-license.org
11//
12// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
13// associated documentation files (the "Software"), to deal in the Software without restriction,
14// including without limitation the rights to use, copy, modify, merge, publish, distribute,
15// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
16// furnished to do so, subject to the following conditions:
17// - The above copyright notice and this permission notice shall be included in all copies or
18// substantial portions of the Software.
19// - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
20// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
23// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25#ifndef PHQ_UNIT_MEMORY_HPP
26#define PHQ_UNIT_MEMORY_HPP
27
28#include <cstddef>
29#include <cstdint>
30#include <functional>
31#include <map>
32#include <ostream>
33#include <string_view>
34#include <unordered_map>
35
36#include "../Base.hpp"
37#include "../Dimension/ElectricCurrent.hpp"
38#include "../Dimension/Length.hpp"
39#include "../Dimension/LuminousIntensity.hpp"
40#include "../Dimension/Mass.hpp"
41#include "../Dimension/SubstanceAmount.hpp"
42#include "../Dimension/Temperature.hpp"
43#include "../Dimension/Time.hpp"
44#include "../Dimensions.hpp"
45#include "../Unit.hpp"
46#include "../UnitSystem.hpp"
47
48namespace PhQ {
49
50namespace Unit {
51
52/// \brief Computer memory units.
53enum class Memory : int8_t {
54 /// \brief Bit (b) memory unit.
55 Bit,
56
57 /// \brief Byte (B) memory unit.
58 Byte,
59
60 /// \brief Kilobit (kb) memory unit.
61 Kilobit,
62
63 /// \brief Kibibit (kib) memory unit.
64 Kibibit,
65
66 /// \brief Kilobyte (kB) memory unit.
68
69 /// \brief Kibibyte (kiB) memory unit.
71
72 /// \brief Megabit (Mb) memory unit.
73 Megabit,
74
75 /// \brief Mebibit (Mib) memory unit.
76 Mebibit,
77
78 /// \brief Megabyte (MB) memory unit.
80
81 /// \brief Mebibyte (MiB) memory unit.
83
84 /// \brief Gigabit (Gb) memory unit.
85 Gigabit,
86
87 /// \brief Gibibit (Gib) memory unit.
88 Gibibit,
89
90 /// \brief Gigabyte (GB) memory unit.
92
93 /// \brief Gibibyte (GiB) memory unit.
95
96 /// \brief Terabit (Tb) memory unit.
97 Terabit,
98
99 /// \brief Tebibit (Tib) memory unit.
100 Tebibit,
101
102 /// \brief Terabyte (TB) memory unit.
103 Terabyte,
104
105 /// \brief Tebibyte (TiB) memory unit.
106 Tebibyte,
107
108 /// \brief Petabit (Pb) memory unit.
109 Petabit,
110
111 /// \brief Pebibit (Pib) memory unit.
112 Pebibit,
113
114 /// \brief Petabyte (PB) memory unit.
115 Petabyte,
116
117 /// \brief Pebibyte (PiB) memory unit.
118 Pebibyte,
119};
120
121} // namespace Unit
122
123/// \brief Standard computer memory unit: bit (b).
124template <>
125inline constexpr const Unit::Memory Standard<Unit::Memory>{Unit::Memory::Bit};
126
127/// \brief Physical dimension set of computer memory units.
128template <>
129inline constexpr const Dimensions RelatedDimensions<Unit::Memory>{Dimensionless};
130
131inline std::ostream& operator<<(std::ostream& stream, const Unit::Memory unit) {
132 stream << Abbreviation(unit);
133 return stream;
134}
135
136namespace Internal {
137
138template <>
139inline const std::map<UnitSystem, Unit::Memory> ConsistentUnits<Unit::Memory>{
144};
145
146template <>
147inline const std::map<Unit::Memory, UnitSystem> RelatedUnitSystems<Unit::Memory>{};
148
149template <>
150inline const std::map<Unit::Memory, std::string_view> Abbreviations<Unit::Memory>{
151 {Unit::Memory::Bit, "b" },
152 {Unit::Memory::Byte, "B" },
153 {Unit::Memory::Kilobit, "kb" },
154 {Unit::Memory::Kibibit, "kib"},
155 {Unit::Memory::Kilobyte, "kB" },
156 {Unit::Memory::Kibibyte, "kiB"},
157 {Unit::Memory::Megabit, "Mb" },
158 {Unit::Memory::Mebibit, "Mib"},
159 {Unit::Memory::Megabyte, "MB" },
160 {Unit::Memory::Mebibyte, "MiB"},
161 {Unit::Memory::Gigabit, "Gb" },
162 {Unit::Memory::Gibibit, "Gib"},
163 {Unit::Memory::Gigabyte, "GB" },
164 {Unit::Memory::Gibibyte, "GiB"},
165 {Unit::Memory::Terabit, "Tb" },
166 {Unit::Memory::Tebibit, "Tib"},
167 {Unit::Memory::Terabyte, "TB" },
168 {Unit::Memory::Tebibyte, "TiB"},
169 {Unit::Memory::Petabit, "Pb" },
170 {Unit::Memory::Pebibit, "Pib"},
171 {Unit::Memory::Petabyte, "PB" },
172 {Unit::Memory::Pebibyte, "PiB"},
173};
174
175template <>
176inline const std::unordered_map<std::string_view, Unit::Memory> Spellings<Unit::Memory>{
177 {"b", Unit::Memory::Bit },
178 {"bit", Unit::Memory::Bit },
179 {"bits", Unit::Memory::Bit },
180 {"B", Unit::Memory::Byte },
181 {"byte", Unit::Memory::Byte },
182 {"bytes", Unit::Memory::Byte },
183 {"kb", Unit::Memory::Kilobit },
184 {"kilobit", Unit::Memory::Kilobit },
185 {"kilobits", Unit::Memory::Kilobit },
186 {"kib", Unit::Memory::Kibibit },
187 {"kibibit", Unit::Memory::Kibibit },
188 {"kibibits", Unit::Memory::Kibibit },
190 {"kilobyte", Unit::Memory::Kilobyte},
191 {"kilobytes", Unit::Memory::Kilobyte},
192 {"kiB", Unit::Memory::Kibibyte},
193 {"kibibyte", Unit::Memory::Kibibyte},
194 {"kibibytes", Unit::Memory::Kibibyte},
195 {"Mb", Unit::Memory::Megabit },
196 {"megabit", Unit::Memory::Megabit },
197 {"megabits", Unit::Memory::Megabit },
198 {"Mib", Unit::Memory::Mebibit },
199 {"mebibit", Unit::Memory::Mebibit },
200 {"mebibits", Unit::Memory::Mebibit },
202 {"megabyte", Unit::Memory::Megabyte},
203 {"megabytes", Unit::Memory::Megabyte},
204 {"MiB", Unit::Memory::Mebibyte},
205 {"mebibyte", Unit::Memory::Mebibyte},
206 {"mebibytes", Unit::Memory::Mebibyte},
207 {"Gb", Unit::Memory::Gigabit },
208 {"gigabit", Unit::Memory::Gigabit },
209 {"gigabits", Unit::Memory::Gigabit },
210 {"Gib", Unit::Memory::Gibibit },
211 {"gibibit", Unit::Memory::Gibibit },
212 {"gibibits", Unit::Memory::Gibibit },
214 {"gigabyte", Unit::Memory::Gigabyte},
215 {"gigabytes", Unit::Memory::Gigabyte},
216 {"GiB", Unit::Memory::Gibibyte},
217 {"gibibyte", Unit::Memory::Gibibyte},
218 {"gibibytes", Unit::Memory::Gibibyte},
219 {"Tb", Unit::Memory::Terabit },
220 {"terabit", Unit::Memory::Terabit },
221 {"terabits", Unit::Memory::Terabit },
222 {"Tib", Unit::Memory::Tebibit },
223 {"tebibit", Unit::Memory::Tebibit },
224 {"tebibits", Unit::Memory::Tebibit },
226 {"terabyte", Unit::Memory::Terabyte},
227 {"terabytes", Unit::Memory::Terabyte},
228 {"TiB", Unit::Memory::Tebibyte},
229 {"tebibyte", Unit::Memory::Tebibyte},
230 {"tebibytes", Unit::Memory::Tebibyte},
231 {"Pb", Unit::Memory::Petabit },
232 {"petabit", Unit::Memory::Petabit },
233 {"petabits", Unit::Memory::Petabit },
234 {"Pib", Unit::Memory::Pebibit },
235 {"pebibit", Unit::Memory::Pebibit },
236 {"pebibits", Unit::Memory::Pebibit },
238 {"petabyte", Unit::Memory::Petabyte},
239 {"petabytes", Unit::Memory::Petabyte},
240 {"PiB", Unit::Memory::Pebibyte},
241 {"pebibyte", Unit::Memory::Pebibyte},
242 {"pebibytes", Unit::Memory::Pebibyte},
243};
244
245template <>
246template <typename NumericType>
247inline constexpr void Conversion<Unit::Memory, Unit::Memory::Bit>::FromStandard(
248 NumericType& /*value*/) noexcept {}
249
250template <>
251template <typename NumericType>
252inline constexpr void Conversion<Unit::Memory, Unit::Memory::Bit>::ToStandard(
253 NumericType& /*value*/) noexcept {}
254
255template <>
256template <typename NumericType>
257inline constexpr void Conversion<Unit::Memory, Unit::Memory::Byte>::FromStandard(
258 NumericType& value) noexcept {
259 value *= static_cast<NumericType>(0.125L);
260}
261
262template <>
263template <typename NumericType>
264inline constexpr void Conversion<Unit::Memory, Unit::Memory::Byte>::ToStandard(
265 NumericType& value) noexcept {
266 value *= static_cast<NumericType>(8.0L);
267}
268
269template <>
270template <typename NumericType>
271inline constexpr void Conversion<Unit::Memory, Unit::Memory::Kilobit>::FromStandard(
272 NumericType& value) noexcept {
273 value *= static_cast<NumericType>(0.001L);
274}
275
276template <>
277template <typename NumericType>
278inline constexpr void Conversion<Unit::Memory, Unit::Memory::Kilobit>::ToStandard(
279 NumericType& value) noexcept {
280 value *= static_cast<NumericType>(1000.0L);
281}
282
283template <>
284template <typename NumericType>
285inline constexpr void Conversion<Unit::Memory, Unit::Memory::Kibibit>::FromStandard(
286 NumericType& value) noexcept {
287 value /= static_cast<NumericType>(1024.0L);
288}
289
290template <>
291template <typename NumericType>
292inline constexpr void Conversion<Unit::Memory, Unit::Memory::Kibibit>::ToStandard(
293 NumericType& value) noexcept {
294 value *= static_cast<NumericType>(1024.0L);
295}
296
297template <>
298template <typename NumericType>
299inline constexpr void Conversion<Unit::Memory, Unit::Memory::Kilobyte>::FromStandard(
300 NumericType& value) noexcept {
301 value /= static_cast<NumericType>(8000.0L);
302}
303
304template <>
305template <typename NumericType>
306inline constexpr void Conversion<Unit::Memory, Unit::Memory::Kilobyte>::ToStandard(
307 NumericType& value) noexcept {
308 value *= static_cast<NumericType>(8000.0L);
309}
310
311template <>
312template <typename NumericType>
313inline constexpr void Conversion<Unit::Memory, Unit::Memory::Kibibyte>::FromStandard(
314 NumericType& value) noexcept {
315 value /= (static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L));
316}
317
318template <>
319template <typename NumericType>
320inline constexpr void Conversion<Unit::Memory, Unit::Memory::Kibibyte>::ToStandard(
321 NumericType& value) noexcept {
322 value *= static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L);
323}
324
325template <>
326template <typename NumericType>
327inline constexpr void Conversion<Unit::Memory, Unit::Memory::Megabit>::FromStandard(
328 NumericType& value) noexcept {
329 value *= static_cast<NumericType>(0.000001L);
330}
331
332template <>
333template <typename NumericType>
334inline constexpr void Conversion<Unit::Memory, Unit::Memory::Megabit>::ToStandard(
335 NumericType& value) noexcept {
336 value *= static_cast<NumericType>(1000000.0L);
337}
338
339template <>
340template <typename NumericType>
341inline constexpr void Conversion<Unit::Memory, Unit::Memory::Mebibit>::FromStandard(
342 NumericType& value) noexcept {
343 value /= (static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L));
344}
345
346template <>
347template <typename NumericType>
348inline constexpr void Conversion<Unit::Memory, Unit::Memory::Mebibit>::ToStandard(
349 NumericType& value) noexcept {
350 value *= static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L);
351}
352
353template <>
354template <typename NumericType>
355inline constexpr void Conversion<Unit::Memory, Unit::Memory::Megabyte>::FromStandard(
356 NumericType& value) noexcept {
357 value /= static_cast<NumericType>(8000000.0L);
358}
359
360template <>
361template <typename NumericType>
362inline constexpr void Conversion<Unit::Memory, Unit::Memory::Megabyte>::ToStandard(
363 NumericType& value) noexcept {
364 value *= static_cast<NumericType>(8000000.0L);
365}
366
367template <>
368template <typename NumericType>
369inline constexpr void Conversion<Unit::Memory, Unit::Memory::Mebibyte>::FromStandard(
370 NumericType& value) noexcept {
371 value /= (static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L)
372 * static_cast<NumericType>(1024.0L));
373}
374
375template <>
376template <typename NumericType>
377inline constexpr void Conversion<Unit::Memory, Unit::Memory::Mebibyte>::ToStandard(
378 NumericType& value) noexcept {
379 value *= static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L)
380 * static_cast<NumericType>(1024.0L);
381}
382
383template <>
384template <typename NumericType>
385inline constexpr void Conversion<Unit::Memory, Unit::Memory::Gigabit>::FromStandard(
386 NumericType& value) noexcept {
387 value *= static_cast<NumericType>(1.0E-9L);
388}
389
390template <>
391template <typename NumericType>
392inline constexpr void Conversion<Unit::Memory, Unit::Memory::Gigabit>::ToStandard(
393 NumericType& value) noexcept {
394 value *= static_cast<NumericType>(1000000000.0L);
395}
396
397template <>
398template <typename NumericType>
399inline constexpr void Conversion<Unit::Memory, Unit::Memory::Gibibit>::FromStandard(
400 NumericType& value) noexcept {
401 value /= (static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
402 * static_cast<NumericType>(1024.0L));
403}
404
405template <>
406template <typename NumericType>
407inline constexpr void Conversion<Unit::Memory, Unit::Memory::Gibibit>::ToStandard(
408 NumericType& value) noexcept {
409 value *= static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
410 * static_cast<NumericType>(1024.0L);
411}
412
413template <>
414template <typename NumericType>
415inline constexpr void Conversion<Unit::Memory, Unit::Memory::Gigabyte>::FromStandard(
416 NumericType& value) noexcept {
417 value /= static_cast<NumericType>(8.0E9L);
418}
419
420template <>
421template <typename NumericType>
422inline constexpr void Conversion<Unit::Memory, Unit::Memory::Gigabyte>::ToStandard(
423 NumericType& value) noexcept {
424 value *= static_cast<NumericType>(8.0E9L);
425}
426
427template <>
428template <typename NumericType>
429inline constexpr void Conversion<Unit::Memory, Unit::Memory::Gibibyte>::FromStandard(
430 NumericType& value) noexcept {
431 value /= (static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L)
432 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L));
433}
434
435template <>
436template <typename NumericType>
437inline constexpr void Conversion<Unit::Memory, Unit::Memory::Gibibyte>::ToStandard(
438 NumericType& value) noexcept {
439 value *= static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L)
440 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L);
441}
442
443template <>
444template <typename NumericType>
445inline constexpr void Conversion<Unit::Memory, Unit::Memory::Terabit>::FromStandard(
446 NumericType& value) noexcept {
447 value *= static_cast<NumericType>(1.0E-12L);
448}
449
450template <>
451template <typename NumericType>
452inline constexpr void Conversion<Unit::Memory, Unit::Memory::Terabit>::ToStandard(
453 NumericType& value) noexcept {
454 value *= static_cast<NumericType>(1.0E12L);
455}
456
457template <>
458template <typename NumericType>
459inline constexpr void Conversion<Unit::Memory, Unit::Memory::Tebibit>::FromStandard(
460 NumericType& value) noexcept {
461 value /= (static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
462 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L));
463}
464
465template <>
466template <typename NumericType>
467inline constexpr void Conversion<Unit::Memory, Unit::Memory::Tebibit>::ToStandard(
468 NumericType& value) noexcept {
469 value *= static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
470 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L);
471}
472
473template <>
474template <typename NumericType>
475inline constexpr void Conversion<Unit::Memory, Unit::Memory::Terabyte>::FromStandard(
476 NumericType& value) noexcept {
477 value /= static_cast<NumericType>(8.0E12L);
478}
479
480template <>
481template <typename NumericType>
482inline constexpr void Conversion<Unit::Memory, Unit::Memory::Terabyte>::ToStandard(
483 NumericType& value) noexcept {
484 value *= static_cast<NumericType>(8.0E12L);
485}
486
487template <>
488template <typename NumericType>
489inline constexpr void Conversion<Unit::Memory, Unit::Memory::Tebibyte>::FromStandard(
490 NumericType& value) noexcept {
491 value /= (static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L)
492 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
493 * static_cast<NumericType>(1024.0L));
494}
495
496template <>
497template <typename NumericType>
498inline constexpr void Conversion<Unit::Memory, Unit::Memory::Tebibyte>::ToStandard(
499 NumericType& value) noexcept {
500 value *= static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L)
501 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
502 * static_cast<NumericType>(1024.0L);
503}
504
505template <>
506template <typename NumericType>
507inline constexpr void Conversion<Unit::Memory, Unit::Memory::Petabit>::FromStandard(
508 NumericType& value) noexcept {
509 value *= static_cast<NumericType>(1.0E-15L);
510}
511
512template <>
513template <typename NumericType>
514inline constexpr void Conversion<Unit::Memory, Unit::Memory::Petabit>::ToStandard(
515 NumericType& value) noexcept {
516 value *= static_cast<NumericType>(1.0E15L);
517}
518
519template <>
520template <typename NumericType>
521inline constexpr void Conversion<Unit::Memory, Unit::Memory::Pebibit>::FromStandard(
522 NumericType& value) noexcept {
523 value /= (static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
524 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
525 * static_cast<NumericType>(1024.0L));
526}
527
528template <>
529template <typename NumericType>
530inline constexpr void Conversion<Unit::Memory, Unit::Memory::Pebibit>::ToStandard(
531 NumericType& value) noexcept {
532 value *= static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
533 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
534 * static_cast<NumericType>(1024.0L);
535}
536
537template <>
538template <typename NumericType>
539inline constexpr void Conversion<Unit::Memory, Unit::Memory::Petabyte>::FromStandard(
540 NumericType& value) noexcept {
541 value /= static_cast<NumericType>(8.0E15L);
542}
543
544template <>
545template <typename NumericType>
546inline constexpr void Conversion<Unit::Memory, Unit::Memory::Petabyte>::ToStandard(
547 NumericType& value) noexcept {
548 value *= static_cast<NumericType>(8.0E15L);
549}
550
551template <>
552template <typename NumericType>
553inline constexpr void Conversion<Unit::Memory, Unit::Memory::Pebibyte>::FromStandard(
554 NumericType& value) noexcept {
555 value /= (static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L)
556 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
557 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L));
558}
559
560template <>
561template <typename NumericType>
562inline constexpr void Conversion<Unit::Memory, Unit::Memory::Pebibyte>::ToStandard(
563 NumericType& value) noexcept {
564 value *= static_cast<NumericType>(8.0L) * static_cast<NumericType>(1024.0L)
565 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L)
566 * static_cast<NumericType>(1024.0L) * static_cast<NumericType>(1024.0L);
567}
568
569template <typename NumericType>
570inline const std::map<Unit::Memory,
571 std::function<void(NumericType* values, const std::size_t size)>>
572 MapOfConversionsFromStandard<Unit::Memory, NumericType>{
573 {Unit::Memory::Bit, Conversions<Unit::Memory, Unit::Memory::Bit>::FromStandard<NumericType> },
575 Conversions<Unit::Memory, Unit::Memory::Byte>::FromStandard<NumericType> },
577 Conversions<Unit::Memory, Unit::Memory::Kilobit>::FromStandard<NumericType> },
579 Conversions<Unit::Memory, Unit::Memory::Kibibit>::FromStandard<NumericType> },
581 Conversions<Unit::Memory, Unit::Memory::Kilobyte>::FromStandard<NumericType>},
583 Conversions<Unit::Memory, Unit::Memory::Kibibyte>::FromStandard<NumericType>},
585 Conversions<Unit::Memory, Unit::Memory::Megabit>::FromStandard<NumericType> },
587 Conversions<Unit::Memory, Unit::Memory::Mebibit>::FromStandard<NumericType> },
589 Conversions<Unit::Memory, Unit::Memory::Megabyte>::FromStandard<NumericType>},
591 Conversions<Unit::Memory, Unit::Memory::Mebibyte>::FromStandard<NumericType>},
593 Conversions<Unit::Memory, Unit::Memory::Gigabit>::FromStandard<NumericType> },
595 Conversions<Unit::Memory, Unit::Memory::Gibibit>::FromStandard<NumericType> },
597 Conversions<Unit::Memory, Unit::Memory::Gigabyte>::FromStandard<NumericType>},
599 Conversions<Unit::Memory, Unit::Memory::Gibibyte>::FromStandard<NumericType>},
601 Conversions<Unit::Memory, Unit::Memory::Terabit>::FromStandard<NumericType> },
603 Conversions<Unit::Memory, Unit::Memory::Tebibit>::FromStandard<NumericType> },
605 Conversions<Unit::Memory, Unit::Memory::Terabyte>::FromStandard<NumericType>},
607 Conversions<Unit::Memory, Unit::Memory::Tebibyte>::FromStandard<NumericType>},
609 Conversions<Unit::Memory, Unit::Memory::Petabit>::FromStandard<NumericType> },
611 Conversions<Unit::Memory, Unit::Memory::Pebibit>::FromStandard<NumericType> },
613 Conversions<Unit::Memory, Unit::Memory::Petabyte>::FromStandard<NumericType>},
615 Conversions<Unit::Memory, Unit::Memory::Pebibyte>::FromStandard<NumericType>},
616};
617
618template <typename NumericType>
619inline const std::map<Unit::Memory,
620 std::function<void(NumericType* const values, const std::size_t size)>>
621 MapOfConversionsToStandard<Unit::Memory, NumericType>{
622 {Unit::Memory::Bit, Conversions<Unit::Memory, Unit::Memory::Bit>::ToStandard<NumericType> },
623 {Unit::Memory::Byte, Conversions<Unit::Memory, Unit::Memory::Byte>::ToStandard<NumericType> },
625 Conversions<Unit::Memory, Unit::Memory::Kilobit>::ToStandard<NumericType> },
627 Conversions<Unit::Memory, Unit::Memory::Kibibit>::ToStandard<NumericType> },
629 Conversions<Unit::Memory, Unit::Memory::Kilobyte>::ToStandard<NumericType>},
631 Conversions<Unit::Memory, Unit::Memory::Kibibyte>::ToStandard<NumericType>},
633 Conversions<Unit::Memory, Unit::Memory::Megabit>::ToStandard<NumericType> },
635 Conversions<Unit::Memory, Unit::Memory::Mebibit>::ToStandard<NumericType> },
637 Conversions<Unit::Memory, Unit::Memory::Megabyte>::ToStandard<NumericType>},
639 Conversions<Unit::Memory, Unit::Memory::Mebibyte>::ToStandard<NumericType>},
641 Conversions<Unit::Memory, Unit::Memory::Gigabit>::ToStandard<NumericType> },
643 Conversions<Unit::Memory, Unit::Memory::Gibibit>::ToStandard<NumericType> },
645 Conversions<Unit::Memory, Unit::Memory::Gigabyte>::ToStandard<NumericType>},
647 Conversions<Unit::Memory, Unit::Memory::Gibibyte>::ToStandard<NumericType>},
649 Conversions<Unit::Memory, Unit::Memory::Terabit>::ToStandard<NumericType> },
651 Conversions<Unit::Memory, Unit::Memory::Tebibit>::ToStandard<NumericType> },
653 Conversions<Unit::Memory, Unit::Memory::Terabyte>::ToStandard<NumericType>},
655 Conversions<Unit::Memory, Unit::Memory::Tebibyte>::ToStandard<NumericType>},
657 Conversions<Unit::Memory, Unit::Memory::Petabit>::ToStandard<NumericType> },
659 Conversions<Unit::Memory, Unit::Memory::Pebibit>::ToStandard<NumericType> },
661 Conversions<Unit::Memory, Unit::Memory::Petabyte>::ToStandard<NumericType>},
663 Conversions<Unit::Memory, Unit::Memory::Pebibyte>::ToStandard<NumericType>},
664};
665
666} // namespace Internal
667
668} // namespace PhQ
669
670#endif // PHQ_UNIT_MEMORY_HPP
Memory
Computer memory units.
Definition Memory.hpp:53
@ Gigabit
Gigabit (Gb) memory unit.
@ Tebibyte
Tebibyte (TiB) memory unit.
@ Gigabyte
Gigabyte (GB) memory unit.
@ Tebibit
Tebibit (Tib) memory unit.
@ Pebibyte
Pebibyte (PiB) memory unit.
@ Pebibit
Pebibit (Pib) memory unit.
@ Megabyte
Megabyte (MB) memory unit.
@ Megabit
Megabit (Mb) memory unit.
@ Terabit
Terabit (Tb) memory unit.
@ Terabyte
Terabyte (TB) memory unit.
@ Gibibit
Gibibit (Gib) memory unit.
@ Petabit
Petabit (Pb) memory unit.
@ Kibibit
Kibibit (kib) memory unit.
@ Kibibyte
Kibibyte (kiB) memory unit.
@ Mebibit
Mebibit (Mib) memory unit.
@ Byte
Byte (B) memory unit.
@ Mebibyte
Mebibyte (MiB) memory unit.
@ Kilobit
Kilobit (kb) memory unit.
@ Petabyte
Petabyte (PB) memory unit.
@ Gibibyte
Gibibyte (GiB) memory unit.
@ Kilobyte
Kilobyte (kB) memory unit.
@ Bit
Bit (b) memory unit.
Namespace that encompasses all of the Physical Quantities library's content.
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)
@ FootPoundSecondRankine
Foot-pound-second-rankine (ft·lbf·s·°R) system.
@ MillimetreGramSecondKelvin
Millimetre-gram-second-kelvin (mm·g·s·K) system.
@ MetreKilogramSecondKelvin
Metre-kilogram-second-kelvin (m·kg·s·K) system.
@ InchPoundSecondRankine
Inch-pound-second-rankine (in·lbf·s·°R) system.
constexpr Dimensions Dimensionless
Dimensionless physical dimension set. This dimension set has all base dimensions of zero....
std::string_view Abbreviation(const Enumeration enumeration)
Returns the abbreviation of a given enumeration value. For example, PhQ::Abbreviation(PhQ::Unit::Time...
Definition Base.hpp:89