mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 04:44:27 +02:00
docs: quick start example updated
This commit is contained in:
@@ -92,13 +92,8 @@ int main()
|
|||||||
constexpr Speed auto v2 = mi_per_h(70.);
|
constexpr Speed auto v2 = mi_per_h(70.);
|
||||||
constexpr Speed auto v3 = avg_speed(220_q_km, 2_q_h);
|
constexpr Speed auto v3 = avg_speed(220_q_km, 2_q_h);
|
||||||
constexpr Speed auto v4 = avg_speed(si::length<si::international::mile>(140), si::time<si::hour>(2));
|
constexpr Speed auto v4 = avg_speed(si::length<si::international::mile>(140), si::time<si::hour>(2));
|
||||||
#if UNITS_DOWNCAST_MODE == 0
|
|
||||||
constexpr Speed auto v5 = quantity_cast<si::speed<si::metre_per_second>>(v3);
|
|
||||||
constexpr Speed auto v6 = quantity_cast<si::dim_speed, si::metre_per_second>(v4);
|
|
||||||
#else
|
|
||||||
constexpr Speed auto v5 = quantity_cast<si::speed<si::metre_per_second>>(v3);
|
constexpr Speed auto v5 = quantity_cast<si::speed<si::metre_per_second>>(v3);
|
||||||
constexpr Speed auto v6 = quantity_cast<si::metre_per_second>(v4);
|
constexpr Speed auto v6 = quantity_cast<si::metre_per_second>(v4);
|
||||||
#endif
|
|
||||||
constexpr Speed auto v7 = quantity_cast<int>(v6);
|
constexpr Speed auto v7 = quantity_cast<int>(v6);
|
||||||
|
|
||||||
std::cout << v1 << '\n'; // 110 km/h
|
std::cout << v1 << '\n'; // 110 km/h
|
||||||
@@ -111,4 +106,4 @@ int main()
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
_Try it on the [Compiler Explorer](https://godbolt.org/z/9fnzfbhb6)._
|
_Try it on the [Compiler Explorer](https://godbolt.org/z/bcb87Kvea)._
|
||||||
|
@@ -66,13 +66,8 @@ of basic library features::
|
|||||||
constexpr Speed auto v2 = mi_per_h(70.);
|
constexpr Speed auto v2 = mi_per_h(70.);
|
||||||
constexpr Speed auto v3 = avg_speed(220_q_km, 2_q_h);
|
constexpr Speed auto v3 = avg_speed(220_q_km, 2_q_h);
|
||||||
constexpr Speed auto v4 = avg_speed(si::length<si::international::mile>(140), si::time<si::hour>(2));
|
constexpr Speed auto v4 = avg_speed(si::length<si::international::mile>(140), si::time<si::hour>(2));
|
||||||
#if UNITS_DOWNCAST_MODE == 0
|
|
||||||
constexpr Speed auto v5 = quantity_cast<si::speed<si::metre_per_second>>(v3);
|
|
||||||
constexpr Speed auto v6 = quantity_cast<si::dim_speed, si::metre_per_second>(v4);
|
|
||||||
#else
|
|
||||||
constexpr Speed auto v5 = quantity_cast<si::speed<si::metre_per_second>>(v3);
|
constexpr Speed auto v5 = quantity_cast<si::speed<si::metre_per_second>>(v3);
|
||||||
constexpr Speed auto v6 = quantity_cast<si::metre_per_second>(v4);
|
constexpr Speed auto v6 = quantity_cast<si::metre_per_second>(v4);
|
||||||
#endif
|
|
||||||
constexpr Speed auto v7 = quantity_cast<int>(v6);
|
constexpr Speed auto v7 = quantity_cast<int>(v6);
|
||||||
|
|
||||||
std::cout << v1 << '\n'; // 110 km/h
|
std::cout << v1 << '\n'; // 110 km/h
|
||||||
@@ -86,7 +81,7 @@ of basic library features::
|
|||||||
|
|
||||||
.. admonition:: Try it on Compiler Explorer
|
.. admonition:: Try it on Compiler Explorer
|
||||||
|
|
||||||
`Example #2 <https://godbolt.org/z/9fnzfbhb6>`_
|
`Example #2 <https://godbolt.org/z/bcb87Kvea>`_
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user