1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>debug_adaptor</title> 5<link rel="stylesheet" href="../../../multiprecision.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Multiprecision"> 8<link rel="up" href="../misc.html" title="Miscellaneous Number Types."> 9<link rel="prev" href="logged_adaptor.html" title="logged_adaptor"> 10<link rel="next" href="visualizers.html" title="Visual C++ Debugger Visualizers"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="logged_adaptor.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../misc.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="visualizers.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="boost_multiprecision.tut.misc.debug_adaptor"></a><a class="link" href="debug_adaptor.html" title="debug_adaptor">debug_adaptor</a> 28</h4></div></div></div> 29<p> 30 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">debug_adaptor</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 31 </p> 32<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">multiprecision</span><span class="special">{</span> 33 34<span class="keyword">template</span> <span class="special"><</span><span class="identifier">Backend</span><span class="special">></span> 35<span class="keyword">class</span> <span class="identifier">debug_adaptor</span><span class="special">;</span> 36 37<span class="special">}}</span> <span class="comment">// namespaces</span> 38</pre> 39<p> 40 The <code class="computeroutput"><span class="identifier">debug_adaptor</span></code> type 41 is used in conjunction with <code class="computeroutput"><span class="identifier">number</span></code> 42 and some other backend type: it acts as a thin wrapper around some other 43 backend to class <code class="computeroutput"><span class="identifier">number</span></code> 44 and intercepts all operations on that object storing the result as a string 45 within itself. 46 </p> 47<p> 48 This type provides <code class="computeroutput"><span class="identifier">numeric_limits</span></code> 49 support whenever the template argument Backend does so. 50 </p> 51<p> 52 This type is particularly useful when your debugger provides a good view 53 of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>: when this is the case multiprecision 54 values can easily be inspected in the debugger by looking at the <code class="computeroutput"><span class="identifier">debug_value</span></code> member of <code class="computeroutput"><span class="identifier">debug_adaptor</span></code>. 55 The down side of this approach is that runtimes are much slower when using 56 this type. Set against that it can make debugging very much easier, certainly 57 much easier than sprinkling code with <code class="computeroutput"><span class="identifier">printf</span></code> 58 statements. 59 </p> 60<p> 61 When used in conjunction with the Visual C++ debugger visualisers, the 62 value of a multiprecision type that uses this backend is displayed in the 63 debugger just a <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 64 (built-in)</a> value would be, here we're inspecting a value of type 65 <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">debug_adaptor</span><span class="special"><</span><span class="identifier">cpp_dec_float</span><span class="special"><</span><span class="number">50</span><span class="special">></span> <span class="special">></span> 66 <span class="special">></span></code>: 67 </p> 68<p> 69 <span class="inlinemediaobject"><img src="../../../../debugger1.png"></span> 70 </p> 71<p> 72 Otherwise you will need to expand out the view and look at the "debug_value" 73 member: 74 </p> 75<p> 76 <span class="inlinemediaobject"><img src="../../../../debugger2.png"></span> 77 </p> 78<p> 79 It works for all the backend types equally too, here it is inspecting a 80 <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">debug_adaptor</span><span class="special"><</span><span class="identifier">gmp_rational</span><span class="special">></span> 81 <span class="special">></span></code>: 82 </p> 83<p> 84 <span class="inlinemediaobject"><img src="../../../../debugger3.png"></span> 85 </p> 86</div> 87<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 88<td align="left"></td> 89<td align="right"><div class="copyright-footer">Copyright © 2002-2020 John 90 Maddock and Christopher Kormanyos<p> 91 Distributed under the Boost Software License, Version 1.0. (See accompanying 92 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 93 </p> 94</div></td> 95</tr></table> 96<hr> 97<div class="spirit-nav"> 98<a accesskey="p" href="logged_adaptor.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../misc.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="visualizers.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 99</div> 100</body> 101</html> 102