docs: quick start example updated with fmt

Compiler Explorer finaly does not time out of fmt library :-)
This commit is contained in:
Mateusz Pusz
2020-09-07 12:45:56 +02:00
parent 93c05b2938
commit 35036ae4d8
2 changed files with 12 additions and 10 deletions

View File

@@ -55,6 +55,7 @@ the below example for a quick preview of basic library features:
```cpp
#include <units/physical/si/speed.h>
#include <units/physical/international/speed.h>
#include <units/format.h>
#include <iostream>
using namespace units::physical;
@@ -72,11 +73,11 @@ int main()
Speed auto v3 = quantity_cast<si::metre_per_second>(v2);
Speed auto v4 = quantity_cast<int>(v3);
std::cout << v1 << '\n'; // 110 km/h
std::cout << v2 << '\n'; // 70 mi/h
std::cout << v3 << '\n'; // 31.2928 m/s
std::cout << v4 << '\n'; // 31 m/s
std::cout << v1 << '\n'; // 110 km/h
std::cout << fmt::format("{}", v2) << '\n'; // 70 mi/h
std::cout << fmt::format("{:%Q in %q}", v3) << '\n'; // 31.2928 in m/s
std::cout << fmt::format("{:%Q}", v4) << '\n'; // 31
}
```
_Try it on the [Compiler Explorer](https://godbolt.org/z/f-f6y6)._
_Try it on the [Compiler Explorer](https://godbolt.org/z/xE91TY)._

View File

@@ -33,6 +33,7 @@ of basic library features::
#include <units/physical/si/speed.h>
#include <units/physical/international/speed.h>
#include <units/format.h>
#include <iostream>
using namespace units::physical;
@@ -50,15 +51,15 @@ of basic library features::
Speed auto v3 = quantity_cast<si::metre_per_second>(v2);
Speed auto v4 = quantity_cast<int>(v3);
std::cout << v1 << '\n'; // 110 km/h
std::cout << v2 << '\n'; // 70 mi/h
std::cout << v3 << '\n'; // 31.2928 m/s
std::cout << v4 << '\n'; // 31 m/s
std::cout << v1 << '\n'; // 110 km/h
std::cout << fmt::format("{}", v2) << '\n'; // 70 mi/h
std::cout << fmt::format("{:%Q in %q}", v3) << '\n'; // 31.2928 in m/s
std::cout << fmt::format("{:%Q}", v4) << '\n'; // 31
}
.. admonition:: Try it on Compiler Explorer
`Example #2 <https://godbolt.org/z/f-f6y6>`_
`Example #2 <https://godbolt.org/z/xE91TY>`_
.. seealso::