mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 20:04:27 +02:00
feat: ppm
parts per million
Co-authored-by: Mateusz Pusz <mateusz.pusz@gmail.com>
This commit is contained in:
committed by
Nebojsa Cvetkovic
parent
1df2cc7b58
commit
a62f061028
@@ -160,6 +160,8 @@ with dimensionless quantities:
|
|||||||
```cpp
|
```cpp
|
||||||
inline constexpr struct percent : named_unit<"%", mag<ratio{1, 100}> * one> {} percent;
|
inline constexpr struct percent : named_unit<"%", mag<ratio{1, 100}> * one> {} percent;
|
||||||
inline constexpr struct per_mille : named_unit<basic_symbol_text{"‰", "%o"}, mag<ratio(1, 1000)> * one> {} per_mille;
|
inline constexpr struct per_mille : named_unit<basic_symbol_text{"‰", "%o"}, mag<ratio(1, 1000)> * one> {} per_mille;
|
||||||
|
inline constexpr struct parts_per_million : named_unit<"ppm", mag<ratio(1, 1'000'000)> * one> {} parts_per_million;
|
||||||
|
inline constexpr auto ppm = parts_per_million;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@@ -605,6 +605,8 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Unit U>
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
inline constexpr struct percent : named_unit<"%", mag<ratio{1, 100}> * one> {} percent;
|
inline constexpr struct percent : named_unit<"%", mag<ratio{1, 100}> * one> {} percent;
|
||||||
inline constexpr struct per_mille : named_unit<basic_symbol_text{"‰", "%o"}, mag<ratio(1, 1000)> * one> {} per_mille;
|
inline constexpr struct per_mille : named_unit<basic_symbol_text{"‰", "%o"}, mag<ratio(1, 1000)> * one> {} per_mille;
|
||||||
|
inline constexpr struct parts_per_million : named_unit<"ppm", mag<ratio(1, 1'000'000)> * one> {} parts_per_million;
|
||||||
|
inline constexpr auto ppm = parts_per_million;
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
||||||
|
@@ -120,6 +120,7 @@ static_assert(unit_symbol(one) == "");
|
|||||||
static_assert(unit_symbol(percent) == "%");
|
static_assert(unit_symbol(percent) == "%");
|
||||||
static_assert(unit_symbol(per_mille) == "‰");
|
static_assert(unit_symbol(per_mille) == "‰");
|
||||||
static_assert(unit_symbol<unit_symbol_formatting{.encoding = ascii}>(per_mille) == "%o");
|
static_assert(unit_symbol<unit_symbol_formatting{.encoding = ascii}>(per_mille) == "%o");
|
||||||
|
static_assert(unit_symbol(parts_per_million) == "ppm");
|
||||||
static_assert(unit_symbol(square(metre)) == "m²");
|
static_assert(unit_symbol(square(metre)) == "m²");
|
||||||
static_assert(unit_symbol<unit_symbol_formatting{.encoding = ascii}>(square(metre)) == "m^2");
|
static_assert(unit_symbol<unit_symbol_formatting{.encoding = ascii}>(square(metre)) == "m^2");
|
||||||
static_assert(unit_symbol(cubic(metre)) == "m³");
|
static_assert(unit_symbol(cubic(metre)) == "m³");
|
||||||
|
Reference in New Issue
Block a user