mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 18:37:15 +02:00
feat: 💥 !data
system renamed to isq::iec80000
(quantity names renamed too)
Relates to #253
This commit is contained in:
@ -150,7 +150,6 @@ class UnitsConan(ConanFile):
|
||||
# rest
|
||||
self.cpp_info.components["core-io"].requires = ["core"]
|
||||
self.cpp_info.components["core-fmt"].requires = ["core", "fmt::fmt"]
|
||||
self.cpp_info.components["data"].requires = ["core"]
|
||||
self.cpp_info.components["isq"].requires = ["core"]
|
||||
self.cpp_info.components["isq-natural"].requires = ["isq"]
|
||||
self.cpp_info.components["si"].requires = ["isq"]
|
||||
@ -161,4 +160,5 @@ class UnitsConan(ConanFile):
|
||||
self.cpp_info.components["si-international"].requires = ["si"]
|
||||
self.cpp_info.components["si-typographic"].requires = ["si"]
|
||||
self.cpp_info.components["si-us"].requires = ["si"]
|
||||
self.cpp_info.components["systems"].requires = ["data", "isq", "isq-natural", "si", "si-cgs", "si-fps", "si-iau", "si-imperial", "si-international", "si-typographic", "si-us"]
|
||||
self.cpp_info.components["isq-iec80000"].requires = ["si"]
|
||||
self.cpp_info.components["systems"].requires = ["isq", "isq-natural", "si", "si-cgs", "si-fps", "si-iau", "si-imperial", "si-international", "si-typographic", "si-us", "isq-iec80000"]
|
||||
|
@ -5,6 +5,7 @@
|
||||
- (!) refactor: output stream operators moved to the `units/quantity_io.h` header file
|
||||
- (!) refactor: Refactored the library file tree
|
||||
- (!) refactor: `quantity::count()` renamed to `quantity::number()`
|
||||
- (!) refactor: `data` system renamed to `isq::iec80000` (quantity names renamed too)
|
||||
- refactor: quantity (kind) point updated to reflect latest changes to `quantity`
|
||||
- refactor: basic concepts, `quantity` and `quantity_cast` refactored
|
||||
- refactor: `abs()` definition refactored to be more explicit about the return type
|
||||
@ -12,6 +13,8 @@
|
||||
- feat: quantity references support added (thanks [@johelegp](https://github.com/johelegp))
|
||||
- feat: interoperability with `std::chrono::duration` and other units libraries
|
||||
- feat: CTAD for dimensionless quantity added
|
||||
- feat: `modulation_rate` support added (thanks [@go2sh](https://github.com/go2sh))
|
||||
- feat: SI prefixes for `isq::iec80000` support added (thanks [@go2sh](https://github.com/go2sh))
|
||||
- perf: preconditions check do not influence the runtime performance of a Release build
|
||||
- perf: `quantity_cast()` generates less assembly instructions
|
||||
- perf: temporary string creation removed from `quantity::op<<()`
|
||||
|
@ -114,11 +114,6 @@ set(unitsSphinxDocs
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/data.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/data/bitrate.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/data/information.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/data/prefixes.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/angle.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/dimensionless.rst"
|
||||
@ -126,6 +121,13 @@ set(unitsSphinxDocs
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/binary_prefixes.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/modulation_rate.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/storage_capacity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/traffic_intensity.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/transfer_rate.rst"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/constants.rst"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/dimensions.rst"
|
||||
|
@ -10,8 +10,3 @@ Systems
|
||||
:maxdepth: 2
|
||||
|
||||
systems/isq
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
systems/data
|
||||
|
@ -1,9 +0,0 @@
|
||||
Data
|
||||
====
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
data/prefixes
|
||||
data/information
|
||||
data/bitrate
|
@ -1,4 +0,0 @@
|
||||
Bitrate
|
||||
=======
|
||||
|
||||
.. doxygenfile:: data/bitrate.h
|
@ -1,4 +0,0 @@
|
||||
Information
|
||||
===========
|
||||
|
||||
.. doxygenfile:: data/information.h
|
@ -1,4 +0,0 @@
|
||||
Prefixes
|
||||
========
|
||||
|
||||
.. doxygenfile:: data/prefixes.h
|
@ -6,6 +6,7 @@ International System of Quantities (ISQ)
|
||||
|
||||
isq/dimensions_and_concepts
|
||||
isq/si
|
||||
isq/iec80000
|
||||
isq/si_cgs
|
||||
isq/si_international
|
||||
isq/si_us
|
||||
|
11
docs/reference/systems/isq/iec80000.rst
Normal file
11
docs/reference/systems/isq/iec80000.rst
Normal file
@ -0,0 +1,11 @@
|
||||
IEC 80000
|
||||
=========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
iec80000/binary_prefixes
|
||||
iec80000/modulation_rate
|
||||
iec80000/storage_capacity
|
||||
iec80000/traffic_intensity
|
||||
iec80000/transfer_rate
|
4
docs/reference/systems/isq/iec80000/binary_prefixes.rst
Normal file
4
docs/reference/systems/isq/iec80000/binary_prefixes.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Binary Prefixes
|
||||
===============
|
||||
|
||||
.. doxygenfile:: iec80000/binary_prefixes.h
|
4
docs/reference/systems/isq/iec80000/modulation_rate.rst
Normal file
4
docs/reference/systems/isq/iec80000/modulation_rate.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Modulation Rate
|
||||
===============
|
||||
|
||||
.. doxygenfile:: iec80000/modulation_rate.h
|
4
docs/reference/systems/isq/iec80000/storage_capacity.rst
Normal file
4
docs/reference/systems/isq/iec80000/storage_capacity.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Sotrage Capacity
|
||||
================
|
||||
|
||||
.. doxygenfile:: iec80000/storage_capacity.h
|
@ -0,0 +1,4 @@
|
||||
Traffic Intensity
|
||||
=================
|
||||
|
||||
.. doxygenfile:: iec80000/traffic_intensity.h
|
4
docs/reference/systems/isq/iec80000/transfer_rate.rst
Normal file
4
docs/reference/systems/isq/iec80000/transfer_rate.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Transfer Rate
|
||||
=============
|
||||
|
||||
.. doxygenfile:: iec80000/transfer_rate.h
|
@ -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)
|
@ -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
|
@ -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
|
@ -26,7 +26,6 @@ find_package(Catch2 CONFIG REQUIRED)
|
||||
|
||||
add_executable(unit_tests_runtime
|
||||
catch_main.cpp
|
||||
digital_info_test.cpp
|
||||
math_test.cpp
|
||||
fmt_test.cpp
|
||||
fmt_units_test.cpp
|
||||
|
@ -1,77 +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.
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <units/data/data.h>
|
||||
#include <units/format.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <sstream>
|
||||
|
||||
using namespace units::data;
|
||||
|
||||
TEST_CASE("operator<< on a data quantity", "[text][ostream]")
|
||||
{
|
||||
std::stringstream stream;
|
||||
|
||||
SECTION("quantity with a predefined unit and prefix")
|
||||
{
|
||||
SECTION("named unit")
|
||||
{
|
||||
stream << 64_q_B;
|
||||
REQUIRE(stream.str() == "64 B");
|
||||
}
|
||||
|
||||
SECTION("prefixed coherent unit")
|
||||
{
|
||||
stream << 256_q_Kib;
|
||||
REQUIRE(stream.str() == "256 Kib");
|
||||
}
|
||||
|
||||
SECTION("prefixed non-coherent unit")
|
||||
{
|
||||
stream << 1024_q_KiB;
|
||||
REQUIRE(stream.str() == "1024 KiB");
|
||||
}
|
||||
|
||||
SECTION("other unit matching prefix")
|
||||
{
|
||||
stream << 8_q_Kib * 8_q_Kib / 2_q_b;
|
||||
REQUIRE(stream.str() == "32 Mib");
|
||||
}
|
||||
SECTION("prefixed coherent unit (SI)") {
|
||||
stream << 32_q_kb;
|
||||
REQUIRE(stream.str() == "32 kb");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("fmt::format on data unit symbols", "[text][fmt]")
|
||||
{
|
||||
SECTION("symbolrate")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1_q_Bd) == "1 Bd");
|
||||
CHECK(fmt::format("{}", 1_q_kBd) == "1 kBd");
|
||||
CHECK(fmt::format("{}", 1_q_MBd) == "1 MBd");
|
||||
CHECK(fmt::format("{}", 1_q_GBd) == "1 GBd");
|
||||
CHECK(fmt::format("{}", 1_q_TBd) == "1 TBd");
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "units/format.h"
|
||||
#include "units/isq/iec80000/iec80000.h"
|
||||
#include "units/isq/si/si.h"
|
||||
#include "units/isq/si/iau/iau.h"
|
||||
#include "units/isq/si/imperial/imperial.h"
|
||||
@ -30,11 +31,13 @@
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
using namespace units::isq::si;
|
||||
using namespace units::isq::si::references;
|
||||
using namespace units::isq::si::international;
|
||||
using namespace units::isq::si::us;
|
||||
using namespace units::isq::si::iau;
|
||||
using namespace units::isq::si::imperial;
|
||||
using namespace units::isq::si::typographic;
|
||||
using namespace units::isq::iec80000::references;
|
||||
|
||||
TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
{
|
||||
@ -97,8 +100,8 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
|
||||
SECTION("density")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1_q_kg_per_m3) == "1 kg/m³");
|
||||
CHECK(fmt::format("{:%Q %Aq}", 1_q_kg_per_m3) == "1 kg/m^3");
|
||||
CHECK(fmt::format("{}", 1_q_kg_per_m3) == "1 kg/m³");
|
||||
CHECK(fmt::format("{:%Q %Aq}", 1_q_kg_per_m3) == "1 kg/m^3");
|
||||
}
|
||||
|
||||
SECTION("resistance")
|
||||
@ -116,13 +119,13 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
|
||||
SECTION("voltage")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1_q_V) == "1 V");
|
||||
CHECK(fmt::format("{}", 1_q_mV) == "1 mV");
|
||||
CHECK(fmt::format("{}", 1_q_uV) == "1 µV");
|
||||
CHECK(fmt::format("{}", 1_q_nV) == "1 nV");
|
||||
CHECK(fmt::format("{}", 1_q_pV) == "1 pV");
|
||||
CHECK(fmt::format("{}", 1_q_V) == "1 V");
|
||||
CHECK(fmt::format("{}", 1_q_mV) == "1 mV");
|
||||
CHECK(fmt::format("{}", 1_q_uV) == "1 µV");
|
||||
CHECK(fmt::format("{}", 1_q_nV) == "1 nV");
|
||||
CHECK(fmt::format("{}", 1_q_pV) == "1 pV");
|
||||
|
||||
CHECK(fmt::format("{:%Q %Aq}", 1_q_uV) == "1 uV");
|
||||
CHECK(fmt::format("{:%Q %Aq}", 1_q_uV) == "1 uV");
|
||||
}
|
||||
|
||||
SECTION("volume")
|
||||
@ -310,6 +313,37 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
CHECK(fmt::format("{}", 1_q_Nm_per_rad) == "1 N ⋅ m/rad");
|
||||
}
|
||||
|
||||
SECTION("storage_capacity")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1 * bit) == "1 bit");
|
||||
CHECK(fmt::format("{}", 1 * kbit) == "1 kbit");
|
||||
CHECK(fmt::format("{}", 1 * Tibit) == "1 Tibit");
|
||||
CHECK(fmt::format("{}", 1 * B) == "1 B");
|
||||
CHECK(fmt::format("{}", 1 * kB) == "1 kB");
|
||||
CHECK(fmt::format("{}", 1 * TiB) == "1 TiB");
|
||||
}
|
||||
|
||||
SECTION("transfer_rate")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1 * (B / s)) == "1 B/s");
|
||||
CHECK(fmt::format("{}", 1 * (kB / s)) == "1 kB/s");
|
||||
CHECK(fmt::format("{}", 1 * (TB / s)) == "1 TB/s");
|
||||
}
|
||||
|
||||
SECTION("traffic_intesity")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1 * E) == "1 E");
|
||||
}
|
||||
|
||||
SECTION("modulation_rate")
|
||||
{
|
||||
using namespace units::isq::iec80000;
|
||||
CHECK(fmt::format("{}", 1 * Bd) == "1 Bd");
|
||||
CHECK(fmt::format("{}", 1 * kBd) == "1 kBd");
|
||||
CHECK(fmt::format("{}", 1 * TBd) == "1 TBd");
|
||||
CHECK(fmt::format("{}", quantity_cast<baud>(4 / (2 * s))) == "2 Bd");
|
||||
}
|
||||
|
||||
SECTION("incoherent units with powers")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1_q_mi * 1_q_mi * 1_q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³");
|
||||
|
@ -44,11 +44,11 @@ add_library(unit_tests_static
|
||||
concepts_test.cpp
|
||||
custom_rep_test_min_expl.cpp
|
||||
custom_unit_test.cpp
|
||||
data_test.cpp
|
||||
dimension_op_test.cpp
|
||||
dimensions_concepts_test.cpp
|
||||
fixed_string_test.cpp
|
||||
fps_test.cpp
|
||||
iec80000_test.cpp
|
||||
kind_test.cpp
|
||||
math_test.cpp
|
||||
ratio_test.cpp
|
||||
|
@ -20,31 +20,41 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/data/data.h>
|
||||
#include <units/isq/iec80000/iec80000.h>
|
||||
|
||||
/* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units::data;
|
||||
using namespace units::isq::si::references;
|
||||
using namespace units::isq::iec80000::references;
|
||||
|
||||
// information
|
||||
|
||||
static_assert(1_q_B == 8_q_b);
|
||||
static_assert(1024_q_b == 1_q_Kib);
|
||||
static_assert(1024_q_B == 1_q_KiB);
|
||||
static_assert(8 * 1024_q_b == 1_q_KiB);
|
||||
static_assert(8 * 1_q_Kib == 1_q_KiB);
|
||||
static_assert(1 * B == 8 * bit);
|
||||
static_assert(1024 * bit == 1 * Kibit);
|
||||
static_assert(1024 * B == 1 * KiB);
|
||||
static_assert(8 * 1024 * bit == 1 * KiB);
|
||||
static_assert(8 * 1 * Kibit == 1 * KiB);
|
||||
|
||||
static_assert(1_q_kb == 1000_q_b);
|
||||
static_assert(2000_q_Mib == 2097152_q_kb);
|
||||
static_assert(1 * kbit == 1000 * bit);
|
||||
static_assert(2000 * Mibit == 2097152 * kbit);
|
||||
|
||||
static_assert(1_q_Kib == 1024_q_b);
|
||||
static_assert(1_q_Mib == 1024_q_Kib);
|
||||
static_assert(1_q_Gib == 1024_q_Mib);
|
||||
static_assert(1_q_Tib == 1024_q_Gib);
|
||||
static_assert(1_q_Pib == 1024_q_Tib);
|
||||
static_assert(1 * Kibit == 1024 * bit);
|
||||
static_assert(1 * Mibit == 1024 * Kibit);
|
||||
static_assert(1 * Gibit == 1024 * Mibit);
|
||||
static_assert(1 * Tibit == 1024 * Gibit);
|
||||
static_assert(1 * Pibit == 1024 * Tibit);
|
||||
static_assert(1 * Eibit == 1024 * Pibit);
|
||||
|
||||
// bitrate
|
||||
// transfer rate
|
||||
|
||||
static_assert(16 * B / (2 * s) == 8 * (B / s));
|
||||
static_assert(120 * kB / (2 * min) == 1000 * (B / s));
|
||||
|
||||
// modulation rate
|
||||
|
||||
static_assert(12 / (2 * s) == 6 * Bd);
|
||||
static_assert(6000 / (3 * s) == 2 * kBd);
|
||||
|
||||
}
|
Reference in New Issue
Block a user