blob: 37de46b701dd6390b14864ca6ee1f72e51fb9e00 [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>debug_adaptor</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="up" href="../misc.html" title="Miscellaneous Number Types.">
<link rel="prev" href="logged_adaptor.html" title="logged_adaptor">
<link rel="next" href="visualizers.html" title="Visual C++ Debugger Visualizers">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<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>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_multiprecision.tut.misc.debug_adaptor"></a><a class="link" href="debug_adaptor.html" title="debug_adaptor">debug_adaptor</a>
</h4></div></div></div>
<p>
<code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</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">&gt;</span></code>
</p>
<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>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">Backend</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">debug_adaptor</span><span class="special">;</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<p>
The <code class="computeroutput"><span class="identifier">debug_adaptor</span></code> type
is used in conjunction with <code class="computeroutput"><span class="identifier">number</span></code>
and some other backend type: it acts as a thin wrapper around some other
backend to class <code class="computeroutput"><span class="identifier">number</span></code>
and intercepts all operations on that object storing the result as a string
within itself.
</p>
<p>
This type provides <code class="computeroutput"><span class="identifier">numeric_limits</span></code>
support whenever the template argument Backend does so.
</p>
<p>
This type is particularly useful when your debugger provides a good view
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
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>.
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 <code class="computeroutput"><span class="identifier">printf</span></code>
statements.
</p>
<p>
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 builtin value would be, here we're inspecting a value of
type <code class="computeroutput"><span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">debug_adaptor</span><span class="special">&lt;</span><span class="identifier">cpp_dec_float</span><span class="special">&lt;</span><span class="number">50</span><span class="special">&gt;</span> <span class="special">&gt;</span>
<span class="special">&gt;</span></code>:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../../debugger1.png"></span>
</p>
<p>
Otherwise you will need to expand out the view and look at the "debug_value"
member:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../../debugger2.png"></span>
</p>
<p>
It works for all the backend types equally too, here it is inspecting a
<code class="computeroutput"><span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">debug_adaptor</span><span class="special">&lt;</span><span class="identifier">gmp_rational</span><span class="special">&gt;</span>
<span class="special">&gt;</span></code>:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../../debugger3.png"></span>
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2013 John Maddock and Christopher Kormanyos<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<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>
</div>
</body>
</html>