boost/libs/multiprecision/doc/tutorial_debug_adaptor.qbk
2021-10-05 21:37:46 +02:00

48 lines
1.8 KiB
Plaintext

[/
Copyright 2011 - 2020 John Maddock.
Copyright 2013 - 2019 Paul A. Bristow.
Copyright 2013 Christopher Kormanyos.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[section:debug_adaptor debug_adaptor]
`#include <boost/multiprecision/debug_adaptor.hpp>`
namespace boost{ namespace multiprecision{
template <Backend>
class debug_adaptor;
}} // namespaces
The `debug_adaptor` type is used in conjunction with `number` and some other backend type: it acts as a thin wrapper around
some other backend to class `number` and intercepts all operations on that object storing the result as a string within itself.
This type provides `numeric_limits` support whenever the template argument Backend does so.
This type is particularly useful when your debugger provides a good view of `std::string`: when this is the case
multiprecision values can easily be inspected in the debugger by looking at the `debug_value` member of `debug_adaptor`.
The down side of this approach is that runtimes are much slower when using this type. Set against that it can make
debugging very much easier, certainly much easier than sprinkling code with `printf` statements.
When used in conjunction with the Visual C++ debugger visualisers, the value of a multiprecision type that uses this
backend is displayed in the debugger just a __fundamental value would be, here we're inspecting a value of type
`number<debug_adaptor<cpp_dec_float<50> > >`:
[$../debugger1.png]
Otherwise you will need to expand out the view and look at the "debug_value" member:
[$../debugger2.png]
It works for all the backend types equally too, here it is inspecting a `number<debug_adaptor<gmp_rational> >`:
[$../debugger3.png]
[endsect] [/section:debug_adaptor debug_adaptor]