Skip to content

Commit aec22fc

Browse files
committed
Allow all types to be shown in example
1 parent c559030 commit aec22fc

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

examples/debugger.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@
55
// This example, when run with the pretty printers, shows how various values are represented
66

77
#include <boost/decimal/decimal32_t.hpp> // For type decimal32_t
8+
#include <boost/decimal/decimal64_t.hpp> // For type decimal64_t
9+
#include <boost/decimal/decimal128_t.hpp> // For type decimal128_t
810
#include <boost/decimal/cmath.hpp> // For nan function to write payload to nans
911
#include <limits>
1012

11-
int main()
13+
template <typename T>
14+
void debug_values()
1215
{
13-
using boost::decimal::decimal32_t;
14-
15-
const decimal32_t max {std::numeric_limits<decimal32_t>::max()};
16-
const decimal32_t min {std::numeric_limits<decimal32_t>::min()};
17-
const decimal32_t short_num {"3.140"};
18-
const decimal32_t pos_inf {std::numeric_limits<decimal32_t>::infinity()};
19-
const decimal32_t neg_inf {-std::numeric_limits<decimal32_t>::infinity()};
16+
const T max {std::numeric_limits<T>::max()};
17+
const T min {std::numeric_limits<T>::min()};
18+
const T short_num {"3.140"};
19+
const T pos_inf {std::numeric_limits<T>::infinity()};
20+
const T neg_inf {-std::numeric_limits<T>::infinity()};
2021

21-
const decimal32_t qnan {std::numeric_limits<decimal32_t>::quiet_NaN()};
22-
const decimal32_t snan {std::numeric_limits<decimal32_t>::signaling_NaN()};
22+
const T qnan {std::numeric_limits<T>::quiet_NaN()};
23+
const T snan {std::numeric_limits<T>::signaling_NaN()};
2324

24-
const decimal32_t payload_nan {boost::decimal::nand32("7")};
25+
const T payload_nan {boost::decimal::nan<T>("7")};
2526

2627
// Break Here:
2728
static_cast<void>(max);
@@ -32,6 +33,13 @@ int main()
3233
static_cast<void>(qnan);
3334
static_cast<void>(snan);
3435
static_cast<void>(payload_nan);
36+
}
37+
38+
int main()
39+
{
40+
debug_values<boost::decimal::decimal32_t>();
41+
debug_values<boost::decimal::decimal64_t>();
42+
debug_values<boost::decimal::decimal128_t>();
3543

3644
return 0;
3745
}

0 commit comments

Comments
 (0)