diff --git a/README.md b/README.md index 8f4f7f40..bb18eb21 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,6 @@ and dimensional analysis can be performed without sacrificing on runtime perform accuracy. Please see the below example for a quick preview of basic library features: ```cpp -#include -#include #include #include #include @@ -132,4 +130,4 @@ int main() } ``` -_Try it on the [Compiler Explorer](https://godbolt.org/z/nhqhT8Mzb)._ +_Try it on the [Compiler Explorer](https://godbolt.org/z/fxcjs19ah)._ diff --git a/docs/getting_started/look_and_feel.md b/docs/getting_started/look_and_feel.md index 42cf6205..c94b12ef 100644 --- a/docs/getting_started/look_and_feel.md +++ b/docs/getting_started/look_and_feel.md @@ -109,8 +109,6 @@ performed without sacrificing accuracy. Please see the below example for a quick === "Header files" ```cpp - #include - #include #include #include #include @@ -150,7 +148,7 @@ performed without sacrificing accuracy. Please see the below example for a quick } ``` -!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/nhqhT8Mzb)" +!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/fxcjs19ah)" !!! note diff --git a/docs/getting_started/quick_start.md b/docs/getting_started/quick_start.md index 71ea1bf9..bde07c8c 100644 --- a/docs/getting_started/quick_start.md +++ b/docs/getting_started/quick_start.md @@ -271,7 +271,6 @@ This introduces an additional type-safety. === "Header files" ```cpp - #include #include #include #include diff --git a/docs/index.md b/docs/index.md index 43e1370c..c474aeaa 100644 --- a/docs/index.md +++ b/docs/index.md @@ -49,7 +49,6 @@ The library source code is hosted on [GitHub](https://github.com/mpusz/mp-units) === "Header files" ```cpp - #include #include #include #include @@ -72,7 +71,7 @@ Output: Harvard Bridge length = 364.4 smoot (2034.6 ft, 620.14 m) ± 1 εar ``` -!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/f8f4KnKh8)" +!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/xexMjMsxn)" ??? question "What is `smoot`?" diff --git a/docs/users_guide/examples/avg_speed.md b/docs/users_guide/examples/avg_speed.md index 9a0073a9..056d03c3 100644 --- a/docs/users_guide/examples/avg_speed.md +++ b/docs/users_guide/examples/avg_speed.md @@ -17,28 +17,28 @@ First, we either import a module or include all the necessary header files and i the identifiers from the `mp_units` namespace: ```cpp title="avg_speed.cpp" linenums="1" ---8<-- "example/avg_speed.cpp:28:46" +--8<-- "example/avg_speed.cpp:28:45" ``` Next, we define two functions calculating average speed based on quantities of fixed units and integral and floating-point representation types, respectively, and a third function that we introduced in the [previous example](hello_units.md): -```cpp title="avg_speed.cpp" linenums="20" ---8<-- "example/avg_speed.cpp:48:62" +```cpp title="avg_speed.cpp" linenums="19" +--8<-- "example/avg_speed.cpp:47:61" ``` We also added a simple utility to print our results: -```cpp title="avg_speed.cpp" linenums="35" ---8<-- "example/avg_speed.cpp:64:70" +```cpp title="avg_speed.cpp" linenums="34" +--8<-- "example/avg_speed.cpp:63:69" ``` Now, let's analyze how those three utility functions behave with different sets of arguments. First, we are going to use quantities of SI units and integral representation: -```cpp title="avg_speed.cpp" linenums="42" ---8<-- "example/avg_speed.cpp:72:86" +```cpp title="avg_speed.cpp" linenums="41" +--8<-- "example/avg_speed.cpp:71:85" ``` The above provides the following output: @@ -60,8 +60,8 @@ representation types (the resulting speed is `108 km/h`). The second scenario is really similar to the previous one, but this time, function arguments have floating-point representation types: -```cpp title="avg_speed.cpp" linenums="57" ---8<-- "example/avg_speed.cpp:88:99" +```cpp title="avg_speed.cpp" linenums="56" +--8<-- "example/avg_speed.cpp:87:98" ``` Conversion from floating-point to integral representation types is @@ -81,8 +81,8 @@ Average speed of a car that makes 220 km in 2 h is 110 km/h. Next, let's do the same for integral and floating-point representations, but this time using international mile: -```cpp title="avg_speed.cpp" linenums="69" ---8<-- "example/avg_speed.cpp:101:132" +```cpp title="avg_speed.cpp" linenums="68" +--8<-- "example/avg_speed.cpp:100:131" ``` One important difference here is the fact that as it is not possible to make a lossless conversion @@ -107,8 +107,8 @@ Please note how the first and third results get truncated using integral represe In the end, we repeat the scenario for CGS units: -```cpp title="avg_speed.cpp" linenums="101" ---8<-- "example/avg_speed.cpp:134:165" +```cpp title="avg_speed.cpp" linenums="100" +--8<-- "example/avg_speed.cpp:133:164" ``` Again, we observe `value_cast` being used in the same places and consistent truncation errors @@ -128,6 +128,6 @@ Average speed of a car that makes 2.2e+07 cm in 7200 s is 110 km/h. The example file ends with a simple `main()` function: -```cpp title="avg_speed.cpp" linenums="133" ---8<-- "example/avg_speed.cpp:167:" +```cpp title="avg_speed.cpp" linenums="132" +--8<-- "example/avg_speed.cpp:166:" ``` diff --git a/docs/users_guide/examples/hello_units.md b/docs/users_guide/examples/hello_units.md index a434e086..981bb1e8 100644 --- a/docs/users_guide/examples/hello_units.md +++ b/docs/users_guide/examples/hello_units.md @@ -18,20 +18,20 @@ First, we either import the `mp_units` module or include the headers for: - text formatting and stream output support. ```cpp title="hello_units.cpp" linenums="1" ---8<-- "example/hello_units.cpp:28:45" +--8<-- "example/hello_units.cpp:28:43" ``` Also, to shorten the definitions, we "import" all the symbols from the `mp_units` namespace. -```cpp title="hello_units.cpp" linenums="18" ---8<-- "example/hello_units.cpp:46:47" +```cpp title="hello_units.cpp" linenums="16" +--8<-- "example/hello_units.cpp:44:45" ``` Next, we define a simple function that calculates the average speed based on the provided arguments of length and time: -```cpp title="hello_units.cpp" linenums="19" ---8<-- "example/hello_units.cpp:48:51" +```cpp title="hello_units.cpp" linenums="17" +--8<-- "example/hello_units.cpp:46:49" ``` The above function template takes any quantities implicitly convertible to `isq::length` @@ -45,16 +45,16 @@ that its quantity type is implicitly convertible to `isq::speed`. type is beneficial for users of such a function as it provides more information of what to expect from a function than just using `auto`. -```cpp title="hello_units.cpp" linenums="23" ---8<-- "example/hello_units.cpp:53:56" +```cpp title="hello_units.cpp" linenums="21" +--8<-- "example/hello_units.cpp:51:54" ``` The above lines explicitly opt into using unit symbols from two systems of units. As this introduces a lot of short identifiers into the current scope, it is not done implicitly while including a header file. -```cpp title="hello_units.cpp" linenums="27" ---8<-- "example/hello_units.cpp:58:64" +```cpp title="hello_units.cpp" linenums="25" +--8<-- "example/hello_units.cpp:56:62" ``` - Lines `27` & `28` create a quantity of kind `isq::length / isq::time` with the numbers @@ -74,8 +74,8 @@ implicitly while including a header file. - Line `33` does a [value-truncating conversion](../framework_basics/value_conversions.md#value-truncating-conversions) of changing the underlying representation type from `double` to `int`. -```cpp title="hello_units.cpp" linenums="34" ---8<-- "example/hello_units.cpp:66" +```cpp title="hello_units.cpp" linenums="32" +--8<-- "example/hello_units.cpp:64" ``` The above presents [various ways to print a quantity](../framework_basics/text_output.md). diff --git a/docs/users_guide/examples/hw_voltage.md b/docs/users_guide/examples/hw_voltage.md index 42ac3060..badd0dc0 100644 --- a/docs/users_guide/examples/hw_voltage.md +++ b/docs/users_guide/examples/hw_voltage.md @@ -21,46 +21,46 @@ of an offset. First we include all the dependencies: ```cpp title="hw_voltage.cpp" linenums="1" ---8<-- "example/hw_voltage.cpp:28:44" +--8<-- "example/hw_voltage.cpp:28:43" ``` Next, we specify the real measurement voltage range to be in the range of [-10, 10]: -```cpp title="hw_voltage.cpp" linenums="18" ---8<-- "example/hw_voltage.cpp:46:49" +```cpp title="hw_voltage.cpp" linenums="17" +--8<-- "example/hw_voltage.cpp:45:48" ``` and provide a storage type and special values for the hardware representation: -```cpp title="hw_voltage.cpp" linenums="22" ---8<-- "example/hw_voltage.cpp:51:57" +```cpp title="hw_voltage.cpp" linenums="21" +--8<-- "example/hw_voltage.cpp:50:56" ``` Finally, we define a quantity point origin, an offset unit that scales the value and uses this origin to offset the zero of the sale, and a dedicated quantity point alias using those: -```cpp title="hw_voltage.cpp" linenums="29" ---8<-- "example/hw_voltage.cpp:61:67" +```cpp title="hw_voltage.cpp" linenums="28" +--8<-- "example/hw_voltage.cpp:60:66" ``` Now, when everything is ready, we can simulate mapping of our hardware register, and provide a helper function that will read the value and construct a quantity point from the obtained copy: -```cpp title="hw_voltage.cpp" linenums="36" ---8<-- "example/hw_voltage.cpp:70:78" +```cpp title="hw_voltage.cpp" linenums="35" +--8<-- "example/hw_voltage.cpp:69:77" ``` We also provide a simple print helper for our quantity points: -```cpp title="hw_voltage.cpp" linenums="45" ---8<-- "example/hw_voltage.cpp:80:84" +```cpp title="hw_voltage.cpp" linenums="44" +--8<-- "example/hw_voltage.cpp:79:83" ``` In the main function we simulate setting of 3 values by our hardware. Each of them is read and printed in the voltage unit used on the hardware as well as in the standard SI unit: -```cpp title="hw_voltage.cpp" linenums="50" ---8<-- "example/hw_voltage.cpp:86:" +```cpp title="hw_voltage.cpp" linenums="49" +--8<-- "example/hw_voltage.cpp:85:" ``` The above program results with the following text output: diff --git a/docs/users_guide/examples/si_constants.md b/docs/users_guide/examples/si_constants.md index 847520f4..05aa1119 100644 --- a/docs/users_guide/examples/si_constants.md +++ b/docs/users_guide/examples/si_constants.md @@ -13,14 +13,14 @@ how [Faster-than-lightspeed Constants](../framework_basics/faster_than_lightspee work in practice. ```cpp title="si_constants.cpp" linenums="1" ---8<-- "example/si_constants.cpp:28:40" +--8<-- "example/si_constants.cpp:28:39" ``` As always, we start with the inclusion of all the needed header files. The main part of the example prints all of the SI-defining constants: -```cpp title="si_constants.cpp" linenums="14" ---8<-- "example/si_constants.cpp:42:" +```cpp title="si_constants.cpp" linenums="13" +--8<-- "example/si_constants.cpp:41:" ``` While analyzing the output of this program (provided below), we can easily notice that a direct 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 41f6d567..f494132e 100644 --- a/docs/users_guide/framework_basics/simple_and_typed_quantities.md +++ b/docs/users_guide/framework_basics/simple_and_typed_quantities.md @@ -83,7 +83,6 @@ Here is a simple example showing how to deal with such quantities: === "Header files" ```cpp - #include #include #include @@ -114,7 +113,7 @@ The code above prints: A car driving 110 km in 2 h has an average speed of 15.28 m/s (55 km/h) ``` -!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/W93ovssda)" +!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/8EPTh8YrE)" ### User-provided unit wrappers @@ -201,7 +200,6 @@ The previous example can be re-typed using typed quantities in the following way === "Header files" ```cpp - #include #include #include #include @@ -231,7 +229,7 @@ The previous example can be re-typed using typed quantities in the following way A car driving 110 km in 2 h has an average speed of 15.28 m/s (55 km/h) ``` -!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/MEK1ooEjo)" +!!! example "[Try it on Compiler Explorer](https://godbolt.org/z/joc4Yn9Mz)" In case we will accidentally make the same calculation error as before, this time, we will get a bit longer error message, this time also containing information about the quantity type: diff --git a/docs/users_guide/use_cases/wide_compatibility.md b/docs/users_guide/use_cases/wide_compatibility.md index b3420d12..aa22ed7d 100644 --- a/docs/users_guide/use_cases/wide_compatibility.md +++ b/docs/users_guide/use_cases/wide_compatibility.md @@ -55,8 +55,6 @@ your code using **mp-units**: === "C++20 with header files" ```cpp - #include - #include #include #include #include @@ -75,8 +73,6 @@ your code using **mp-units**: === "C++20 with header files + libfmt" ```cpp - #include - #include #include #include #include @@ -101,8 +97,6 @@ your code using **mp-units**: #include import mp_units; #else - #include - #include #include #include #include