mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-29 18:07:16 +02:00
docs: "hello units" example updated with dimensions output
This commit is contained in:
@ -120,11 +120,11 @@ int main()
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
std::cout << std::setw(10) << std::setfill('*') << v2 << '\n'; // ***70 mi/h
|
||||
std::cout << std::format("{:*^10}\n", v3); // *110 km/h*
|
||||
std::println("{:%N in %U}", v4); // 70 in mi/h
|
||||
std::println("{:%N in %U of %D}", v4); // 70 in mi/h of LT⁻¹
|
||||
std::println("{:{%N:.2f}%?%U}", v5); // 30.56 m/s
|
||||
std::println("{:{%N:.2f}%?{%U:n}}", v6); // 31.29 m s⁻¹
|
||||
std::println("{:{%N:.2f}%?{%U:dn}}", v6); // 31.29 m⋅s⁻¹
|
||||
std::println("{:%N}", v7); // 31
|
||||
}
|
||||
```
|
||||
|
||||
_Try it on the [Compiler Explorer](https://godbolt.org/z/hWzxf1j1M)._
|
||||
_Try it on the [Compiler Explorer](https://godbolt.org/z/n8GEdfeed)._
|
||||
|
@ -99,9 +99,9 @@ performed without sacrificing accuracy. Please see the below example for a quick
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
std::cout << std::setw(10) << std::setfill('*') << v2 << '\n'; // ***70 mi/h
|
||||
std::cout << std::format("{:*^10}\n", v3); // *110 km/h*
|
||||
std::println("{:%N in %U}", v4); // 70 in mi/h
|
||||
std::println("{:%N in %U of %D}", v4); // 70 in mi/h of LT⁻¹
|
||||
std::println("{:{%N:.2f}%?%U}", v5); // 30.56 m/s
|
||||
std::println("{:{%N:.2f}%?{%U:n}}", v6); // 31.29 m s⁻¹
|
||||
std::println("{:{%N:.2f}%?{%U:dn}}", v6); // 31.29 m⋅s⁻¹
|
||||
std::println("{:%N}", v7); // 31
|
||||
}
|
||||
```
|
||||
@ -143,14 +143,14 @@ performed without sacrificing accuracy. Please see the below example for a quick
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
std::cout << std::setw(10) << std::setfill('*') << v2 << '\n'; // ***70 mi/h
|
||||
std::cout << std::format("{:*^10}\n", v3); // *110 km/h*
|
||||
std::println("{:%N in %U}", v4); // 70 in mi/h
|
||||
std::println("{:%N in %U of %D}", v4); // 70 in mi/h of LT⁻¹
|
||||
std::println("{:{%N:.2f}%?%U}", v5); // 30.56 m/s
|
||||
std::println("{:{%N:.2f}%?{%U:n}}", v6); // 31.29 m s⁻¹
|
||||
std::println("{:{%N:.2f}%?{%U:dn}}", v6); // 31.29 m⋅s⁻¹
|
||||
std::println("{:%N}", v7); // 31
|
||||
}
|
||||
```
|
||||
|
||||
!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/hWzxf1j1M)"
|
||||
!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/n8GEdfeed)"
|
||||
|
||||
!!! note
|
||||
|
||||
|
@ -58,11 +58,11 @@ int main()
|
||||
constexpr quantity v6 = value_cast<m / s>(v4);
|
||||
constexpr quantity v7 = value_cast<int>(v6);
|
||||
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
std::cout << std::setw(10) << std::setfill('*') << v2 << '\n'; // ***70 mi/h
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:*^10}\n", v3); // *110 km/h*
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:%N in %U}\n", v4); // 70 in mi/h
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:{%N:.2f}%?%U}\n", v5); // 30.56 in m/s
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:{%N:.2f}%?{%U:n}}\n", v6); // 31.29 in m s⁻¹
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:%N}\n", v7); // 31
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
std::cout << std::setw(10) << std::setfill('*') << v2 << '\n'; // ***70 mi/h
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:*^10}\n", v3); // *110 km/h*
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:%N in %U of %D}\n", v4); // 70 in mi/h of LT⁻¹
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:{%N:.2f}%?%U}\n", v5); // 30.56 in m/s
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:{%N:.2f}%?{%U:dn}}\n", v6); // 31.29 in m⋅s⁻¹
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:%N}\n", v7); // 31
|
||||
}
|
||||
|
Reference in New Issue
Block a user