mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01:33 +02:00
feat: EQUIV{...}
replaced with [...]
in the text output of common units
This commit is contained in:
@ -304,10 +304,10 @@ std::cout << 1 * rad + 1 * deg << "\n";
|
||||
prints:
|
||||
|
||||
```text
|
||||
40771 EQUIV{[1/25146 mi], [1/15625 km]}
|
||||
108167 EQUIV{[1/50292 mi], [1/57875 nmi]}
|
||||
23 EQUIV{[1/5 km/h], [1/18 m/s]}
|
||||
183.142 EQUIV{[1/π°], [1/180 rad]}
|
||||
40771 [(1/25146 mi), (1/15625 km)]
|
||||
108167 [(1/50292 mi), (1/57875 nmi)]
|
||||
23 [(1/5 km/h), (1/18 m/s)]
|
||||
183.142 [(1/π°), (1/180 rad)]
|
||||
```
|
||||
|
||||
Thanks to the above, it might be easier for the user to reason about the magnitude of the resulting
|
||||
|
@ -802,7 +802,7 @@ template<typename CharT, std::output_iterator<CharT> Out, typename U, typename..
|
||||
constexpr Out unit_symbol_impl(Out out, const common_unit<U, Rest...>&, const unit_symbol_formatting& fmt,
|
||||
bool negative_power)
|
||||
{
|
||||
constexpr std::string_view prefix("EQUIV{");
|
||||
constexpr std::string_view prefix("[");
|
||||
constexpr std::string_view separator(", ");
|
||||
auto print_unit = [&]<Unit Arg>(Arg) {
|
||||
constexpr auto u = get_common_unit_in(common_unit<U, Rest...>{}, Arg{});
|
||||
@ -814,7 +814,7 @@ constexpr Out unit_symbol_impl(Out out, const common_unit<U, Rest...>&, const un
|
||||
detail::copy(std::begin(separator), std::end(separator), out);
|
||||
print_unit(Arg{});
|
||||
});
|
||||
*out++ = '}';
|
||||
*out++ = ']';
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -204,13 +204,13 @@ static_assert(unit_symbol(mag<2> / (mag<π> * mag<e>)*one) == "(2 e⁻¹ π⁻¹
|
||||
static_assert(unit_symbol<usf{.solidus = always}>(mag<2> / (mag<π> * mag<e>)*one) == "(2/(e π))");
|
||||
|
||||
// common units
|
||||
static_assert(unit_symbol(get_common_unit(kilo<metre>, mile)) == "EQUIV{(1/25146 mi), (1/15625 km)}");
|
||||
static_assert(unit_symbol(get_common_unit(kilo<metre> / hour, metre / second)) == "EQUIV{(1/5 km/h), (1/18 m/s)}");
|
||||
static_assert(unit_symbol(get_common_unit(kilo<metre>, mile)) == "[(1/25146 mi), (1/15625 km)]");
|
||||
static_assert(unit_symbol(get_common_unit(kilo<metre> / hour, metre / second)) == "[(1/5 km/h), (1/18 m/s)]");
|
||||
static_assert(unit_symbol(get_common_unit(kilo<metre> / hour, metre / second) / second) ==
|
||||
"EQUIV{(1/5 km/h), (1/18 m/s)}/s");
|
||||
"[(1/5 km/h), (1/18 m/s)]/s");
|
||||
static_assert(unit_symbol(get_common_unit(kilo<metre> / hour, metre / second) * second) ==
|
||||
"EQUIV{(1/5 km/h), (1/18 m/s)} s");
|
||||
static_assert(unit_symbol(get_common_unit(radian, degree)) == "EQUIV{(1/π°), (1/180 rad)}");
|
||||
"[(1/5 km/h), (1/18 m/s)] s");
|
||||
static_assert(unit_symbol(get_common_unit(radian, degree)) == "[(1/π°), (1/180 rad)]");
|
||||
|
||||
// derived units
|
||||
static_assert(unit_symbol(one) == ""); // NOLINT(readability-container-size-empty)
|
||||
|
Reference in New Issue
Block a user