forked from mpusz/mp-units
feat: 💥 !data system renamed to isq::iec80000 (quantity names renamed too)
Relates to #253
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
# systems
|
||||
add_subdirectory(data)
|
||||
add_subdirectory(isq)
|
||||
add_subdirectory(isq-iec80000)
|
||||
add_subdirectory(isq-natural)
|
||||
add_subdirectory(si)
|
||||
add_subdirectory(si-cgs)
|
||||
@@ -38,8 +38,8 @@ add_subdirectory(si-us)
|
||||
# wrapper for all the systems
|
||||
add_library(mp-units-systems INTERFACE)
|
||||
target_link_libraries(mp-units-systems INTERFACE
|
||||
mp-units::data
|
||||
mp-units::isq
|
||||
mp-units::isq-iec80000
|
||||
mp-units::isq-natural
|
||||
mp-units::si
|
||||
mp-units::si-cgs
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
// 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 <units/data/information.h>
|
||||
#include <units/derived_dimension.h>
|
||||
#include <units/isq/si/time.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::data {
|
||||
|
||||
struct bit_per_second : unit<bit_per_second> {};
|
||||
struct dim_bitrate : derived_dimension<dim_bitrate, bit_per_second, exponent<dim_information, 1>, exponent<isq::si::dim_time, -1>> {};
|
||||
|
||||
struct kibibit_per_second : deduced_unit<kibibit_per_second, dim_bitrate, kibibit, isq::si::second> {};
|
||||
struct mebibit_per_second : deduced_unit<mebibit_per_second, dim_bitrate, mebibit, isq::si::second> {};
|
||||
struct gibibit_per_second : deduced_unit<gibibit_per_second, dim_bitrate, gibibit, isq::si::second> {};
|
||||
struct tebibit_per_second : deduced_unit<tebibit_per_second, dim_bitrate, tebibit, isq::si::second> {};
|
||||
struct pebibit_per_second : deduced_unit<pebibit_per_second, dim_bitrate, pebibit, isq::si::second> {};
|
||||
|
||||
struct kilobit_per_second : deduced_unit<kilobit_per_second, dim_bitrate, kilobit, isq::si::second> {};
|
||||
struct megabit_per_second : deduced_unit<megabit_per_second, dim_bitrate, megabit, isq::si::second> {};
|
||||
struct gigabit_per_second : deduced_unit<gigabit_per_second, dim_bitrate, gigabit, isq::si::second> {};
|
||||
struct terabit_per_second : deduced_unit<terabit_per_second, dim_bitrate, terabit, isq::si::second> {};
|
||||
struct petabit_per_second : deduced_unit<petabit_per_second, dim_bitrate, petabit, isq::si::second> {};
|
||||
|
||||
template<typename T>
|
||||
concept Bitrate = QuantityOf<T, dim_bitrate>;
|
||||
|
||||
template<UnitOf<dim_bitrate> U, Representation Rep = double>
|
||||
using bitrate = quantity<dim_bitrate, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// bits
|
||||
constexpr auto operator"" _q_b_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<bit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Kib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<kibibit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Mib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<mebibit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Gib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<gibibit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Tib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<tebibit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Pib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<pebibit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
constexpr auto operator"" _q_kb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<kilobit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Mb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<megabit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Gb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<gigabit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Tb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<terabit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Pb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return bitrate<petabit_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
namespace references {
|
||||
|
||||
inline constexpr auto b_per_s = reference<dim_bitrate, bit_per_second>{};
|
||||
inline constexpr auto Kib_per_s = reference<dim_bitrate, kibibit_per_second>{};
|
||||
inline constexpr auto Mib_per_s = reference<dim_bitrate, mebibit_per_second>{};
|
||||
inline constexpr auto Gib_per_s = reference<dim_bitrate, gibibit_per_second>{};
|
||||
inline constexpr auto Tib_per_s = reference<dim_bitrate, tebibit_per_second>{};
|
||||
inline constexpr auto Pib_per_s = reference<dim_bitrate, pebibit_per_second>{};
|
||||
|
||||
inline constexpr auto kb_per_s = reference<dim_bitrate, kilobit_per_second>{};
|
||||
inline constexpr auto Mb_per_s = reference<dim_bitrate, megabit_per_second>{};
|
||||
inline constexpr auto Gb_per_s = reference<dim_bitrate, gigabit_per_second>{};
|
||||
inline constexpr auto Tb_per_s = reference<dim_bitrate, terabit_per_second>{};
|
||||
inline constexpr auto Pb_per_s = reference<dim_bitrate, petabit_per_second>{};
|
||||
|
||||
} // namespace references
|
||||
|
||||
} // namespace units::data
|
||||
@@ -1,115 +0,0 @@
|
||||
// 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 <units/reference.h>
|
||||
#include <units/base_dimension.h>
|
||||
#include <units/isq/si/prefixes.h>
|
||||
#include <units/data/prefixes.h>
|
||||
#include <units/unit.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::data {
|
||||
|
||||
struct bit : named_unit<bit, "b", prefix> {};
|
||||
struct kibibit : prefixed_unit<kibibit, kibi, bit> {};
|
||||
struct mebibit : prefixed_unit<mebibit, mebi, bit> {};
|
||||
struct gibibit : prefixed_unit<gibibit, gibi, bit> {};
|
||||
struct tebibit : prefixed_unit<tebibit, tebi, bit> {};
|
||||
struct pebibit : prefixed_unit<pebibit, pebi, bit> {};
|
||||
|
||||
struct si_bit : alias_unit<bit, "b", isq::si::prefix> {};
|
||||
struct kilobit : prefixed_unit<kilobit, isq::si::kilo, si_bit> {};
|
||||
struct megabit : prefixed_unit<megabit, isq::si::mega, si_bit> {};
|
||||
struct gigabit : prefixed_unit<gigabit, isq::si::giga, si_bit> {};
|
||||
struct terabit : prefixed_unit<terabit, isq::si::tera, si_bit> {};
|
||||
struct petabit : prefixed_unit<petabit, isq::si::peta, si_bit> {};
|
||||
|
||||
struct byte : named_scaled_unit<byte, "B", prefix, ratio(8), bit> {};
|
||||
struct kibibyte : prefixed_unit<kibibyte, kibi, byte> {};
|
||||
struct mebibyte : prefixed_unit<mebibyte, mebi, byte> {};
|
||||
struct gibibyte : prefixed_unit<gibibyte, gibi, byte> {};
|
||||
struct tebibyte : prefixed_unit<tebibyte, tebi, byte> {};
|
||||
struct pebibyte : prefixed_unit<pebibyte, pebi, byte> {};
|
||||
|
||||
struct dim_information : base_dimension<"information", bit> {};
|
||||
|
||||
template<typename T>
|
||||
concept Information = QuantityOf<T, dim_information>;
|
||||
|
||||
template<UnitOf<dim_information> U, Representation Rep = double>
|
||||
using information = quantity<dim_information, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// bits
|
||||
constexpr auto operator"" _q_b(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<bit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Kib(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<kibibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Mib(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<mebibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Gib(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<gibibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Tib(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<tebibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Pib(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<pebibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
// bits (SI)
|
||||
constexpr auto operator"" _q_kb(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<kilobit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Mb(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<megabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Gb(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<gigabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Tb(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<terabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Pb(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<petabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
// bytes
|
||||
constexpr auto operator"" _q_B(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<byte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_KiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<kibibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_MiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<mebibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_GiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<gibibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_TiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<tebibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_PiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return information<pebibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
namespace references {
|
||||
|
||||
inline constexpr auto b = reference<dim_information, bit>{};
|
||||
|
||||
inline constexpr auto Kib = reference<dim_information, kibibit>{};
|
||||
inline constexpr auto Mib = reference<dim_information, mebibit>{};
|
||||
inline constexpr auto Gib = reference<dim_information, gibibit>{};
|
||||
inline constexpr auto Tib = reference<dim_information, tebibit>{};
|
||||
inline constexpr auto Pib = reference<dim_information, pebibit>{};
|
||||
|
||||
inline constexpr auto kb = reference<dim_information, kilobit>{};
|
||||
inline constexpr auto Mb = reference<dim_information, megabit>{};
|
||||
inline constexpr auto Gb = reference<dim_information, gigabit>{};
|
||||
inline constexpr auto Tb = reference<dim_information, terabit>{};
|
||||
inline constexpr auto Pb = reference<dim_information, petabit>{};
|
||||
|
||||
inline constexpr auto B = reference<dim_information, byte>{};
|
||||
inline constexpr auto KiB = reference<dim_information, kibibyte>{};
|
||||
inline constexpr auto MiB = reference<dim_information, mebibyte>{};
|
||||
inline constexpr auto GiB = reference<dim_information, gibibyte>{};
|
||||
inline constexpr auto TiB = reference<dim_information, tebibyte>{};
|
||||
inline constexpr auto PiB = reference<dim_information, pebibyte>{};
|
||||
|
||||
} // namespace references
|
||||
|
||||
} // namespace units::data
|
||||
@@ -1,62 +0,0 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2021 Christoph Seitz
|
||||
//
|
||||
// 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 <units/isq/si/frequency.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::data {
|
||||
|
||||
struct baud : alias_unit<isq::si::hertz, "Bd", isq::si::prefix> {};
|
||||
struct kilobaud : prefixed_alias_unit<isq::si::kilohertz, isq::si::kilo, baud> {};
|
||||
struct megabaud : prefixed_alias_unit<isq::si::megahertz, isq::si::mega, baud> {};
|
||||
struct gigabaud : prefixed_alias_unit<isq::si::gigahertz, isq::si::giga, baud> {};
|
||||
struct terabaud : prefixed_alias_unit<isq::si::terahertz, isq::si::tera, baud> {};
|
||||
struct petabaud : prefixed_alias_unit<isq::si::petahertz, isq::si::peta, baud> {};
|
||||
|
||||
template<UnitOf<isq::si::dim_frequency> U, Representation Rep = double>
|
||||
using symbolrate = quantity<isq::si::dim_frequency, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
constexpr auto operator"" _q_Bd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return symbolrate<baud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_kBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return symbolrate<kilobaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_MBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return symbolrate<megabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_GBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return symbolrate<gigabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_TBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return symbolrate<terabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_PBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return symbolrate<petabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
namespace references {
|
||||
|
||||
inline constexpr auto Bd = reference<isq::si::dim_frequency, baud>{};
|
||||
inline constexpr auto kBd = reference<isq::si::dim_frequency, kilobaud>{};
|
||||
inline constexpr auto MBd = reference<isq::si::dim_frequency, megabaud>{};
|
||||
inline constexpr auto GBd = reference<isq::si::dim_frequency, gigabaud>{};
|
||||
inline constexpr auto TBd = reference<isq::si::dim_frequency, terabaud>{};
|
||||
inline constexpr auto PBd = reference<isq::si::dim_frequency, petabaud>{};
|
||||
|
||||
} // namespace references
|
||||
|
||||
} // namespace units::data
|
||||
@@ -22,4 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
add_units_module(data mp-units::core)
|
||||
add_units_module(isq-iec80000 mp-units::si)
|
||||
+9
-9
@@ -24,15 +24,15 @@
|
||||
|
||||
#include <units/prefix.h>
|
||||
|
||||
namespace units::data {
|
||||
namespace units::isq::iec80000 {
|
||||
|
||||
struct prefix : prefix_family {};
|
||||
struct binary_prefix : prefix_family {};
|
||||
|
||||
struct kibi : units::prefix<kibi, prefix, "Ki", ratio( 1'024)> {};
|
||||
struct mebi : units::prefix<mebi, prefix, "Mi", ratio( 1'048'576)> {};
|
||||
struct gibi : units::prefix<gibi, prefix, "Gi", ratio( 1'073'741'824)> {};
|
||||
struct tebi : units::prefix<tebi, prefix, "Ti", ratio( 1'099'511'627'776)> {};
|
||||
struct pebi : units::prefix<pebi, prefix, "Pi", ratio( 1'125'899'906'842'624)> {};
|
||||
struct exbi : units::prefix<exbi, prefix, "Ei", ratio(1'152'921'504'606'846'976)> {};
|
||||
struct kibi : units::prefix<kibi, binary_prefix, "Ki", ratio( 1'024)> {};
|
||||
struct mebi : units::prefix<mebi, binary_prefix, "Mi", ratio( 1'048'576)> {};
|
||||
struct gibi : units::prefix<gibi, binary_prefix, "Gi", ratio( 1'073'741'824)> {};
|
||||
struct tebi : units::prefix<tebi, binary_prefix, "Ti", ratio( 1'099'511'627'776)> {};
|
||||
struct pebi : units::prefix<pebi, binary_prefix, "Pi", ratio( 1'125'899'906'842'624)> {};
|
||||
struct exbi : units::prefix<exbi, binary_prefix, "Ei", ratio(1'152'921'504'606'846'976)> {};
|
||||
|
||||
} // namespace units::data
|
||||
} // namespace units::isq::iec80000
|
||||
+4
-4
@@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/data/information.h>
|
||||
#include <units/data/bitrate.h>
|
||||
#include <units/data/symbolrate.h>
|
||||
#include <units/data/prefixes.h>
|
||||
#include <units/isq/iec80000/modulation_rate.h>
|
||||
#include <units/isq/iec80000/storage_capacity.h>
|
||||
#include <units/isq/iec80000/traffic_intensity.h>
|
||||
#include <units/isq/iec80000/transfer_rate.h>
|
||||
@@ -0,0 +1,74 @@
|
||||
// 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 <units/isq/si/frequency.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::isq::iec80000 {
|
||||
|
||||
struct baud : alias_unit<si::hertz, "Bd", si::prefix> {};
|
||||
struct kilobaud : prefixed_alias_unit<si::kilohertz, si::kilo, baud> {};
|
||||
struct megabaud : prefixed_alias_unit<si::megahertz, si::mega, baud> {};
|
||||
struct gigabaud : prefixed_alias_unit<si::gigahertz, si::giga, baud> {};
|
||||
struct terabaud : prefixed_alias_unit<si::terahertz, si::tera, baud> {};
|
||||
struct petabaud : prefixed_alias_unit<si::petahertz, si::peta, baud> {};
|
||||
struct exabaud : prefixed_alias_unit<si::exahertz, si::exa, baud> {};
|
||||
struct zettabaud : prefixed_alias_unit<si::zettahertz, si::zetta, baud> {};
|
||||
struct yottabaud : prefixed_alias_unit<si::yottahertz, si::yotta, baud> {};
|
||||
|
||||
// TODO alias_dimension
|
||||
using dim_modulation_rate = si::dim_frequency;
|
||||
|
||||
template<UnitOf<dim_modulation_rate> U, Representation Rep = double>
|
||||
using modulation_rate = quantity<dim_modulation_rate, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
constexpr auto operator"" _q_Bd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<baud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_kBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<kilobaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_MBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<megabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_GBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<gigabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_TBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<terabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_PBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<petabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_EBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<exabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_ZBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<zettabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_YBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return modulation_rate<yottabaud, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
namespace references {
|
||||
|
||||
inline constexpr auto Bd = reference<dim_modulation_rate, baud>{};
|
||||
inline constexpr auto kBd = reference<dim_modulation_rate, kilobaud>{};
|
||||
inline constexpr auto MBd = reference<dim_modulation_rate, megabaud>{};
|
||||
inline constexpr auto GBd = reference<dim_modulation_rate, gigabaud>{};
|
||||
inline constexpr auto TBd = reference<dim_modulation_rate, terabaud>{};
|
||||
inline constexpr auto PBd = reference<dim_modulation_rate, petabaud>{};
|
||||
inline constexpr auto EBd = reference<dim_modulation_rate, exabaud>{};
|
||||
inline constexpr auto ZBd = reference<dim_modulation_rate, zettabaud>{};
|
||||
inline constexpr auto YBd = reference<dim_modulation_rate, yottabaud>{};
|
||||
|
||||
} // namespace references
|
||||
|
||||
} // namespace units::isq::iec80000
|
||||
@@ -0,0 +1,161 @@
|
||||
// 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 <units/base_dimension.h>
|
||||
#include <units/isq/iec80000/binary_prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
|
||||
namespace units::isq::iec80000 {
|
||||
|
||||
struct bit : named_unit<bit, "bit", si::prefix> {};
|
||||
struct kilobit : prefixed_unit<kilobit, si::kilo, bit> {};
|
||||
struct megabit : prefixed_unit<megabit, si::mega, bit> {};
|
||||
struct gigabit : prefixed_unit<gigabit, si::giga, bit> {};
|
||||
struct terabit : prefixed_unit<terabit, si::tera, bit> {};
|
||||
struct petabit : prefixed_unit<petabit, si::peta, bit> {};
|
||||
struct exabit : prefixed_unit<exabit, si::exa, bit> {};
|
||||
struct zettabit : prefixed_unit<zettabit, si::zetta, bit> {};
|
||||
struct yottabit : prefixed_unit<yottabit, si::yotta, bit> {};
|
||||
|
||||
struct binary_prefix_bit : alias_unit<bit, "bit", binary_prefix> {};
|
||||
struct kibibit : prefixed_unit<kibibit, kibi, binary_prefix_bit> {};
|
||||
struct mebibit : prefixed_unit<mebibit, mebi, binary_prefix_bit> {};
|
||||
struct gibibit : prefixed_unit<gibibit, gibi, binary_prefix_bit> {};
|
||||
struct tebibit : prefixed_unit<tebibit, tebi, binary_prefix_bit> {};
|
||||
struct pebibit : prefixed_unit<pebibit, pebi, binary_prefix_bit> {};
|
||||
struct exbibit : prefixed_unit<exbibit, exbi, binary_prefix_bit> {};
|
||||
|
||||
struct byte : named_scaled_unit<byte, "B", si::prefix, ratio(8), bit> {};
|
||||
struct kilobyte : prefixed_unit<kilobyte, si::kilo, byte> {};
|
||||
struct megabyte : prefixed_unit<megabyte, si::mega, byte> {};
|
||||
struct gigabyte : prefixed_unit<gigabyte, si::giga, byte> {};
|
||||
struct terabyte : prefixed_unit<terabyte, si::tera, byte> {};
|
||||
struct petabyte : prefixed_unit<petabyte, si::peta, byte> {};
|
||||
struct exabyte : prefixed_unit<exabyte, si::exa, byte> {};
|
||||
struct zettabyte : prefixed_unit<zettabyte, si::zetta, byte> {};
|
||||
struct yottabyte : prefixed_unit<yottabyte, si::yotta, byte> {};
|
||||
|
||||
struct binary_prefix_byte : alias_unit<byte, "B", binary_prefix> {};
|
||||
struct kibibyte : prefixed_unit<kibibyte, kibi, binary_prefix_byte> {};
|
||||
struct mebibyte : prefixed_unit<mebibyte, mebi, binary_prefix_byte> {};
|
||||
struct gibibyte : prefixed_unit<gibibyte, gibi, binary_prefix_byte> {};
|
||||
struct tebibyte : prefixed_unit<tebibyte, tebi, binary_prefix_byte> {};
|
||||
struct pebibyte : prefixed_unit<pebibyte, pebi, binary_prefix_byte> {};
|
||||
// struct exbibyte : prefixed_unit<exbibyte, exbi, binary_prefix_byte> {};
|
||||
|
||||
struct dim_storage_capacity : base_dimension<"M", byte> {};
|
||||
|
||||
template<typename T>
|
||||
concept StorageCapacity = QuantityOf<T, dim_storage_capacity>;
|
||||
|
||||
template<UnitOf<dim_storage_capacity> U, Representation Rep = double>
|
||||
using storage_capacity = quantity<dim_storage_capacity, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// bits
|
||||
constexpr auto operator"" _q_bit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<bit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
constexpr auto operator"" _q_kbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<kilobit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Mbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<megabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Gbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<gigabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Tbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<terabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Pbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<petabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Ebit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<exabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Zbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<zettabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Ybit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<yottabit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
constexpr auto operator"" _q_Kibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<kibibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Mibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<mebibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Gibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<gibibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Tibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<tebibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Pibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<pebibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_Eibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<exbibit, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
// bytes
|
||||
constexpr auto operator"" _q_B(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<byte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
constexpr auto operator"" _q_kB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<kilobyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_MB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<megabyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_GB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<gigabyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_TB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<terabyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_PB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<petabyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_EB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<exabyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_ZB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<zettabyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_YB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<yottabyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
constexpr auto operator"" _q_KiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<kibibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_MiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<mebibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_GiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<gibibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_TiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<tebibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_PiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<pebibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
// constexpr auto operator"" _q_EiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return storage_capacity<exbibyte, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
namespace references {
|
||||
|
||||
// bits
|
||||
inline constexpr auto bit = reference<dim_storage_capacity, iec80000::bit>{};
|
||||
|
||||
inline constexpr auto kbit = reference<dim_storage_capacity, kilobit>{};
|
||||
inline constexpr auto Mbit = reference<dim_storage_capacity, megabit>{};
|
||||
inline constexpr auto Gbit = reference<dim_storage_capacity, gigabit>{};
|
||||
inline constexpr auto Tbit = reference<dim_storage_capacity, terabit>{};
|
||||
inline constexpr auto Pbit = reference<dim_storage_capacity, petabit>{};
|
||||
inline constexpr auto Ebit = reference<dim_storage_capacity, exabit>{};
|
||||
inline constexpr auto Zbit = reference<dim_storage_capacity, zettabit>{};
|
||||
inline constexpr auto Ybit = reference<dim_storage_capacity, yottabit>{};
|
||||
|
||||
inline constexpr auto Kibit = reference<dim_storage_capacity, kibibit>{};
|
||||
inline constexpr auto Mibit = reference<dim_storage_capacity, mebibit>{};
|
||||
inline constexpr auto Gibit = reference<dim_storage_capacity, gibibit>{};
|
||||
inline constexpr auto Tibit = reference<dim_storage_capacity, tebibit>{};
|
||||
inline constexpr auto Pibit = reference<dim_storage_capacity, pebibit>{};
|
||||
inline constexpr auto Eibit = reference<dim_storage_capacity, exbibit>{};
|
||||
|
||||
// bytes
|
||||
inline constexpr auto B = reference<dim_storage_capacity, byte>{};
|
||||
|
||||
inline constexpr auto kB = reference<dim_storage_capacity, kilobyte>{};
|
||||
inline constexpr auto MB = reference<dim_storage_capacity, megabyte>{};
|
||||
inline constexpr auto GB = reference<dim_storage_capacity, gigabyte>{};
|
||||
inline constexpr auto TB = reference<dim_storage_capacity, terabyte>{};
|
||||
inline constexpr auto PB = reference<dim_storage_capacity, petabyte>{};
|
||||
inline constexpr auto EB = reference<dim_storage_capacity, exabyte>{};
|
||||
inline constexpr auto ZB = reference<dim_storage_capacity, zettabyte>{};
|
||||
inline constexpr auto YB = reference<dim_storage_capacity, yottabyte>{};
|
||||
|
||||
inline constexpr auto KiB = reference<dim_storage_capacity, kibibyte>{};
|
||||
inline constexpr auto MiB = reference<dim_storage_capacity, mebibyte>{};
|
||||
inline constexpr auto GiB = reference<dim_storage_capacity, gibibyte>{};
|
||||
inline constexpr auto TiB = reference<dim_storage_capacity, tebibyte>{};
|
||||
inline constexpr auto PiB = reference<dim_storage_capacity, pebibyte>{};
|
||||
// inline constexpr auto EiB = reference<dim_storage_capacity, exbibyte>{};
|
||||
|
||||
} // namespace references
|
||||
|
||||
} // namespace units::isq::iec80000
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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 <units/base_dimension.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
|
||||
namespace units::isq::iec80000 {
|
||||
|
||||
struct erlang : named_unit<erlang, "E", no_prefix> {};
|
||||
|
||||
struct dim_traffic_intensity : base_dimension<"A", erlang> {};
|
||||
|
||||
template<typename T>
|
||||
concept TrafficIntensity = QuantityOf<T, dim_traffic_intensity>;
|
||||
|
||||
template<UnitOf<dim_traffic_intensity> U, Representation Rep = double>
|
||||
using traffic_intensity = quantity<dim_traffic_intensity, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
constexpr auto operator"" _q_E(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return traffic_intensity<erlang, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
namespace references {
|
||||
|
||||
inline constexpr auto E = reference<dim_traffic_intensity, erlang>{};
|
||||
|
||||
} // namespace references
|
||||
|
||||
} // namespace units::isq::iec80000
|
||||
@@ -0,0 +1,64 @@
|
||||
// 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 <units/derived_dimension.h>
|
||||
#include <units/isq/iec80000/storage_capacity.h>
|
||||
#include <units/isq/si/time.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::isq::iec80000 {
|
||||
|
||||
struct byte_per_second : unit<byte_per_second> {};
|
||||
struct dim_transfer_rate : derived_dimension<dim_transfer_rate, byte_per_second, exponent<dim_storage_capacity, 1>, exponent<si::dim_time, -1>> {};
|
||||
|
||||
struct kilobyte_per_second : deduced_unit<kilobyte_per_second, dim_transfer_rate, kilobyte, si::second> {};
|
||||
struct megabyte_per_second : deduced_unit<megabyte_per_second, dim_transfer_rate, megabyte, si::second> {};
|
||||
struct gigabyte_per_second : deduced_unit<gigabyte_per_second, dim_transfer_rate, gigabyte, si::second> {};
|
||||
struct terabyte_per_second : deduced_unit<terabyte_per_second, dim_transfer_rate, terabyte, si::second> {};
|
||||
struct petabyte_per_second : deduced_unit<petabyte_per_second, dim_transfer_rate, petabyte, si::second> {};
|
||||
struct exabyte_per_second : deduced_unit<exabyte_per_second, dim_transfer_rate, exabyte, si::second> {};
|
||||
struct zettabyte_per_second : deduced_unit<zettabyte_per_second, dim_transfer_rate, zettabyte, si::second> {};
|
||||
struct yottabyte_per_second : deduced_unit<yottabyte_per_second, dim_transfer_rate, yottabyte, si::second> {};
|
||||
|
||||
template<typename T>
|
||||
concept TransferRate = QuantityOf<T, dim_transfer_rate>;
|
||||
|
||||
template<UnitOf<dim_transfer_rate> U, Representation Rep = double>
|
||||
using transfer_rate = quantity<dim_transfer_rate, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
constexpr auto operator"" _q_B_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<byte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_kB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<kilobyte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_MB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<megabyte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_GB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<gigabyte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_TB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<terabyte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_PB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<petabyte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_EB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<exabyte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_ZB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<zettabyte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
constexpr auto operator"" _q_YB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range<std::int64_t>(l)); return transfer_rate<yottabyte_per_second, std::int64_t>(static_cast<std::int64_t>(l)); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::isq::iec80000
|
||||
Reference in New Issue
Block a user