Prefixed units support redesigned
This commit is contained in:
1 parent
95028d10a7
commit
b864461636
30 files changed
+284
-236
No files matched your search
@@ -33,13 +33,11 @@ namespace data {
|
||||
template<typename T>
|
||||
concept DigitalInformation = units::QuantityOf<T, digital_information>;
|
||||
|
||||
using namespace units::hacks;
|
||||
|
||||
struct data_prefix;
|
||||
|
||||
struct bit : units::coherent_derived_unit<bit, decltype("b"_fs), digital_information, data_prefix> {};
|
||||
struct kilobit : units::derived_unit<bit, decltype("Kib"_fs), digital_information, units::ratio<1'024>> {};
|
||||
struct byte : units::derived_unit<byte, decltype("B"_fs), digital_information, units::ratio<8>> {};
|
||||
struct bit : units::coherent_derived_unit<bit, "b", digital_information, data_prefix> {};
|
||||
struct kilobit : units::derived_unit<bit, "Kib", digital_information, units::ratio<1'024>> {};
|
||||
struct byte : units::derived_unit<byte, "B", digital_information, units::ratio<8>> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
|
||||
@@ -48,6 +48,12 @@ TEST_CASE("operator<< on a quantity", "[text][ostream]")
|
||||
stream << 72.5kJ;
|
||||
REQUIRE(stream.str() == "72.5 kJ");
|
||||
}
|
||||
|
||||
SECTION("unit with a prefix")
|
||||
{
|
||||
stream << 125us;
|
||||
REQUIRE(stream.str() == "125 µs");
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("quantity with a predefined dimension but unknown unit")
|
||||
@@ -172,4 +178,13 @@ TEST_CASE("operator<< on a quantity", "[text][ostream]")
|
||||
// }
|
||||
|
||||
// Restate operator<< definitions in terms of std::format to make I/O manipulators apply to whole objects
|
||||
// rather than their parts
|
||||
// rather than their parts
|
||||
|
||||
|
||||
// Giving a precision specification
|
||||
// in the chrono-format-spec is valid only for std::chrono::duration types where the representation type Rep
|
||||
// is a floating-point type. For all other Rep types, a format_error shall be thrown if the chrono-format-spec
|
||||
// contains a precision specification.
|
||||
|
||||
// string s = format("{:=>8}", 42ms); // value of s is "====42ms"
|
||||
|
||||
@@ -35,12 +35,10 @@ namespace {
|
||||
template<typename T>
|
||||
concept DigitalInformation = units::QuantityOf<T, digital_information>;
|
||||
|
||||
using namespace units::hacks;
|
||||
|
||||
struct data_prefix {};
|
||||
|
||||
struct bit : units::coherent_derived_unit<bit, decltype("b"_fs), digital_information, data_prefix> {};
|
||||
struct byte : units::derived_unit<byte, decltype("B"_fs), digital_information, units::ratio<8>> {};
|
||||
struct bit : units::coherent_derived_unit<bit, "b", digital_information, data_prefix> {};
|
||||
struct byte : units::derived_unit<byte, "B", digital_information, units::ratio<8>> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
@@ -65,11 +63,11 @@ namespace {
|
||||
|
||||
// power spectral density
|
||||
struct power_spectral_density : derived_dimension<power_spectral_density, units::exp<voltage, 2>, units::exp<frequency, -1>> {};
|
||||
struct sq_volt_per_hertz : coherent_derived_unit<sq_volt_per_hertz, decltype("V^2/Hz"_fs), power_spectral_density> {};
|
||||
struct sq_volt_per_hertz : coherent_derived_unit<sq_volt_per_hertz, "V^2/Hz", power_spectral_density> {};
|
||||
|
||||
// amplitude spectral density
|
||||
struct amplitude_spectral_density : derived_dimension<amplitude_spectral_density, units::exp<voltage, 1>, units::exp<frequency, -1, 2>> {};
|
||||
struct volt_per_sqrt_hertz : coherent_derived_unit<volt_per_sqrt_hertz, decltype("V/Hz^(1/2)"_fs), amplitude_spectral_density> {};
|
||||
struct volt_per_sqrt_hertz : coherent_derived_unit<volt_per_sqrt_hertz, "V/Hz^(1/2)", amplitude_spectral_density> {};
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
Reference in new issue
Block a user