// The MIT License (MIT) // // Copyright (c) 2018 Mateusz Pusz // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #pragma once #include #include #include #include #include namespace units::data { struct bit : named_unit {}; struct kibibit : prefixed_unit {}; struct mebibit : prefixed_unit {}; struct gibibit : prefixed_unit {}; struct tebibit : prefixed_unit {}; struct pebibit : prefixed_unit {}; struct byte : named_scaled_unit {}; struct kibibyte : prefixed_unit {}; struct mebibyte : prefixed_unit {}; struct gibibyte : prefixed_unit {}; struct tebibyte : prefixed_unit {}; struct pebibyte : prefixed_unit {}; struct dim_information : base_dimension<"information", bit> {}; template concept Information = QuantityOf; template U, QuantityValue Rep = double> using information = quantity; inline namespace literals { // bits constexpr auto operator"" _q_b(unsigned long long l) { return information(l); } constexpr auto operator"" _q_Kib(unsigned long long l) { return information(l); } constexpr auto operator"" _q_Mib(unsigned long long l) { return information(l); } constexpr auto operator"" _q_Gib(unsigned long long l) { return information(l); } constexpr auto operator"" _q_Tib(unsigned long long l) { return information(l); } constexpr auto operator"" _q_Pib(unsigned long long l) { return information(l); } // bytes constexpr auto operator"" _q_B(unsigned long long l) { return information(l); } constexpr auto operator"" _q_KiB(unsigned long long l) { return information(l); } constexpr auto operator"" _q_MiB(unsigned long long l) { return information(l); } constexpr auto operator"" _q_GiB(unsigned long long l) { return information(l); } constexpr auto operator"" _q_TiB(unsigned long long l) { return information(l); } constexpr auto operator"" _q_PiB(unsigned long long l) { return information(l); } } // namespace literals namespace unit_constants { inline constexpr auto b = information{}; inline constexpr auto Kib = information{}; inline constexpr auto Mib = information{}; inline constexpr auto Gib = information{}; inline constexpr auto Tib = information{}; inline constexpr auto Pib = information{}; inline constexpr auto B = information{}; inline constexpr auto KiB = information{}; inline constexpr auto MiB = information{}; inline constexpr auto GiB = information{}; inline constexpr auto TiB = information{}; inline constexpr auto PiB = information{}; } // namespace unit_constants } // namespace units::data