From 7985ea29699c1d9f49a5c89faf0a8a456c692787 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 18 Aug 2023 18:37:12 +0200 Subject: [PATCH] docs: `auto` replaced with type placeholders in code examples --- docs/getting_started/quick_start.md | 12 ++++++------ .../simple_and_typed_quantities.md | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/getting_started/quick_start.md b/docs/getting_started/quick_start.md index cb834224..8d9736e4 100644 --- a/docs/getting_started/quick_start.md +++ b/docs/getting_started/quick_start.md @@ -13,7 +13,7 @@ The quantity is created by multiplying a number with a predefined unit: using namespace mp_units; -auto q = 42 * si::metre; +quantity q = 42 * si::metre; ``` !!! note @@ -30,7 +30,7 @@ an optional unit symbol: using namespace mp_units; using namespace mp_units::si::unit_symbols; -auto q = 42 * m; +quantity q = 42 * m; ``` !!! note @@ -48,7 +48,7 @@ function: using namespace mp_units; -auto q = make_quantity(42); +quantity q = make_quantity(42); ``` @@ -57,7 +57,7 @@ auto q = make_quantity(42); Sometimes it might be awkward to type some derived units: ```cpp -auto speed = 60 * (km / h); +quantity speed = 60 * (km / h); ``` !!! note @@ -70,7 +70,7 @@ wrapper for it with: ```cpp constexpr auto kmph = km / h; -auto speed = 60 * kmph; +quantity speed = 60 * kmph; ``` or even: @@ -79,7 +79,7 @@ or even: constexpr auto kilometre = si::kilo; constexpr auto kilometre_per_hour = kilometre / si::hour; constexpr auto kmph = kilometre_per_hour; -auto speed = 60 * kmph; +quantity speed = 60 * kmph; ``` !!! note diff --git a/docs/users_guide/framework_basics/simple_and_typed_quantities.md b/docs/users_guide/framework_basics/simple_and_typed_quantities.md index da372526..781ba4fe 100644 --- a/docs/users_guide/framework_basics/simple_and_typed_quantities.md +++ b/docs/users_guide/framework_basics/simple_and_typed_quantities.md @@ -66,9 +66,9 @@ int main() { using namespace mp_units::si::unit_symbols; - const auto distance = 110 * km; - const auto duration = 2 * h; - const auto speed = avg_speed(distance, duration); + const quantity distance = 110 * km; + const quantity duration = 2 * h; + const quantity speed = avg_speed(distance, duration); std::cout << "A car driving " << distance << " in " << duration << " has an average speed of " << speed @@ -82,7 +82,7 @@ The code above prints: A car driving 110 km in 2 h has an average speed of 15.2778 m/s (55 km/h) ``` -!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/W6Ej7aqxj)" +!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/4zecYqn5z)" ### Easy to understand compilation error messages @@ -140,9 +140,9 @@ constexpr quantity avg_speed(quantity d, int main() { - const auto distance = isq::distance(110 * km); - const auto duration = isq::time(2 * h); - const auto speed = avg_speed(distance, duration); + const quantity distance = isq::distance(110 * km); + const quantity duration = isq::time(2 * h); + const quantity speed = avg_speed(distance, duration); std::cout << "A car driving " << distance << " in " << duration << " has an average speed of " << speed @@ -154,7 +154,7 @@ int main() A car driving 110 km in 2 h has an average speed of 15.2778 m/s (55 km/h) ``` -!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/98YP8j9b4)" +!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/jhfWjGadz)" In case we will accidentally make the same calculation error as before, this time, we will get a bit longer error message also containing information about the quantity type: