mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 04:14:27 +02:00
Merge pull request #544 from nebkat/patch-1
feat: `ppm` parts per million
This commit is contained in:
@@ -160,6 +160,8 @@ with dimensionless quantities:
|
||||
```cpp
|
||||
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 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
|
||||
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 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
|
||||
|
||||
|
||||
|
@@ -120,6 +120,7 @@ static_assert(unit_symbol(one) == "");
|
||||
static_assert(unit_symbol(percent) == "%");
|
||||
static_assert(unit_symbol(per_mille) == "‰");
|
||||
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<unit_symbol_formatting{.encoding = ascii}>(square(metre)) == "m^2");
|
||||
static_assert(unit_symbol(cubic(metre)) == "m³");
|
||||
|
Reference in New Issue
Block a user