You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/modules/ROOT/pages/examples.adoc
+63-16Lines changed: 63 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,48 +153,95 @@ This example could be extended with the simple moving average to create full ban
153
153
== Formatting
154
154
155
155
Boost.Decimal allows you to format your output with both `<format>` and `<fmt/format.h>` depending on your compiler support.
156
+
pass:[{fmt}] support is available starting with pass:[C++14] so long as you have the library available, but `<format>` requires pass:[C++20] and compiler support
156
157
157
-
[#examples_std_format]
158
-
=== `<format>`
158
+
[#examples_fmt_format]
159
+
=== `<fmt/format.hpp>`
159
160
160
-
If your compiler provides `<format>` you can use that to format the output of your values:
161
+
We also provide support for pass:[{fmt}] so you can easily just swap the namespaces and headers on the above example:
161
162
162
163
[source, c++]
163
164
----
164
-
#include <boost/decimal.hpp>
165
+
// Copyright 2025 Matt Borland
166
+
// Distributed under the Boost Software License, Version 1.0.
167
+
// https://www.boost.org/LICENSE_1_0.txt
168
+
//
169
+
// This example demonstrates usage and formatting of decimal types with fmt
170
+
171
+
#include <boost/decimal/decimal32_t.hpp> // For type decimal32_t
172
+
#include <boost/decimal/decimal64_t.hpp> // For type decimal64_t
173
+
#include <boost/decimal/fmt_format.hpp> // For {fmt} support
0 commit comments