Skip to content

Commit 89565de

Browse files
committed
Restructure the examples page
1 parent 48cefaa commit 89565de

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

doc/modules/ROOT/pages/examples.adoc

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ https://www.boost.org/LICENSE_1_0.txt
1111
All examples can be found in the library `examples/` folder as well.
1212

1313
[#examples_construction]
14-
== Basic construction
15-
16-
This example can be found in the `examples/` folder as https://github.com/cppalliance/decimal/blob/develop/examples/basic_construction.cpp[basic_construction.cpp]
17-
14+
== Basic Construction
15+
.This example demonstrates the basic use of the various constructors offered by the decimal types
16+
====
1817
[source, c++]
1918
----
2019
include::example$basic_construction.cpp[]
2120
----
2221

23-
The expected output from this example is:
24-
----
22+
.Expected Output
23+
....
2524
Val_1: 100
2625
Val_2: 100
2726
Val_3: -100
@@ -30,58 +29,60 @@ Underflow constructs zero
3029
NaN constructs NaN
3130
Values constructed from const char* and std::string are the same
3231
Can not construct from invalid string
33-
----
32+
....
33+
====
3434
3535
[#examples_promotion]
3636
== Promotion and Mixed Decimal Arithmetic
3737
38-
This example can be found in the `examples/` folder as https://github.com/cppalliance/decimal/blob/develop/examples/promotion.cpp[promotion.cpp]
39-
38+
.This example demonstrates the behaviors of promotion between types, and mixed decimal type arithmetic
39+
====
4040
[source, c++]
4141
----
4242
include::example$promotion.cpp[]
4343
----
4444

45-
Expected Output:
46-
----
45+
.Expected Output:
46+
....
4747
decimal32_t value (a): 5.2
4848
decimal64_t value (b): 3.9
4949
a is greater than b
5050
5.2 is less than 1e+385
5151
1e+385 is now less than inf
5252
The result of a + b is a decimal64_t: 9.1
53-
----
53+
....
54+
====
5455
5556
[#examples_charconv]
5657
== `<charconv>`
5758
58-
This example can be found in the `examples/` folder as https://github.com/cppalliance/decimal/blob/develop/examples/charconv.cpp[charconv.cpp]
59-
59+
.This example demonstrates the fundamentals of the `<charconv>` like functions provided by the library
60+
====
6061
[source, c++]
6162
----
6263
include::example$charconv.cpp[]
6364
----
6465

65-
Output:
66-
----
66+
.Expected Output:
67+
....
6768
Initial decimal: -7123450
6869
Value from string: 3.1415
6970
Value in scientific format: -7.12345e+06
7071
Value in scientific format with precision 20: -7.12345000000000000000e+06
71-
----
72+
....
73+
====
7274
7375
[#examples_generic_programming]
7476
== Generic Programming
75-
76-
This example can be found in the `examples/` folder as https://github.com/cppalliance/decimal/blob/develop/examples/adl.cpp[adl.cpp].
77-
77+
.This example demonstrates how to write generic code that accepts both built-in floating point types, and decimal floating point values from this library
78+
====
7879
[source, c++]
7980
----
8081
include::example$adl.cpp[]
8182
----
8283

8384
Expected Output:
84-
----
85+
....
8586
Float:
8687
sin(-0.5) = -0.479426
8788
-sin(0.5) = -0.479426
@@ -137,8 +138,8 @@ pass:[{fmt}] support is available starting with pass:[C++14] so long as you have
137138
[#examples_fmt_format]
138139
=== `<fmt/format.hpp>`
139140

140-
This example can be found in the `examples/` folder as https://github.com/cppalliance/decimal/blob/develop/examples/fmt_format.cpp[fmt_format.cpp].
141-
141+
.This example demonstrates the various formatting options provided by the library to support usage of pass:[{fmt}]
142+
====
142143
[source, c++]
143144
----
144145
// Copyright 2025 Matt Borland
@@ -184,7 +185,7 @@ int main()
184185
----
185186
186187
Expected Output:
187-
----
188+
....
188189
Default Format:
189190
3.14
190191
3.141
@@ -200,7 +201,8 @@ Scientific Format with Specified Precision:
200201
Scientific Format with Specified Precision and Padding:
201202
03.140e+00
202203
03.141e+00
203-
----
204+
....
205+
====
204206

205207
IMPORTANT: If you are using the convenience header `<boost/decimal.hpp>` the header `<boost/decimal/fmt_format.hpp>` is *NOT* automatically included since it requires an external library.
206208
You must include it yourself.
@@ -209,15 +211,16 @@ You must include it yourself.
209211
=== `<format>`
210212

211213
Taking the above example of pass:[{fmt}] and replacing all instances of `namespace fmt` with `namespace std` gives us another working example.
212-
This example can be found in the `examples/` folder as https://github.com/cppalliance/decimal/blob/develop/examples/format.cpp[format.cpp]
213214

215+
.This example demonstrates how to use `<format>` with the library in-place or in addition to pass:[{fmt}]
216+
====
214217
[source, c++]
215218
----
216219
include::example$format.cpp[]
217220
----
218221
219-
Expected Output:
220-
----
222+
.Expected Output:
223+
....
221224
Default Format:
222225
3.14
223226
3.141
@@ -233,16 +236,13 @@ Scientific Format with Specified Precision:
233236
Scientific Format with Specified Precision and Padding:
234237
03.140e+00
235238
03.141e+00
236-
----
239+
....
240+
====
237241

238242

239243
[#examples_print]
240-
== `<print>`
241-
242-
We can make one final change to our `<format>` example where instead of using `std::cout`, we use pass:[C++23's] `<print>`.
243-
This example can be found in the `examples/` folder as https://github.com/cppalliance/decimal/blob/develop/examples/print.cpp[print.cpp].
244-
245-
.`<print>` Example
244+
=== `<print>`
245+
.This example demonstrates how to use `<print>` with the library
246246
====
247247
[source, c++]
248248
----

0 commit comments

Comments
 (0)