• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Design Rationale</title>
5<link rel="stylesheet" href="../../math.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Math Toolkit 2.12.0">
8<link rel="up" href="../fp_facets.html" title="Facets for Floating-Point Infinities and NaNs">
9<link rel="prev" href="portability.html" title="Portability">
10<link rel="next" href="../next_float.html" title="Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values">
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="portability.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../fp_facets.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="../next_float.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="math_toolkit.fp_facets.rationale"></a><a class="link" href="rationale.html" title="Design Rationale">Design Rationale</a>
28</h3></div></div></div>
29<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
30<li class="listitem">
31            The flags are implemented as a const data member of the facet. Facets
32            are reference counted, and locales can share facets. Therefore changing
33            the flags of a facet would have effects that are hard to predict. An
34            alternative design would be to implement the flags using <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">xalloc</span></code> and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">iword</span></code>.
35            Then one could safely modify the flags, and one could define manipulators
36            that do so. However, for that to work with dynamically linked libraries,
37            a <code class="computeroutput"><span class="special">.</span><span class="identifier">cpp</span></code>
38            file would have to be added to the library. It was judged be more desirable
39            to have a header-only library, than to have mutable flags and manipulators.
40          </li>
41<li class="listitem">
42            The facet <code class="computeroutput"><span class="identifier">nonfinite_num_put</span></code>
43            throws an exception when the <code class="computeroutput"><span class="identifier">trap_infinity</span></code>
44            or <code class="computeroutput"><span class="identifier">trap_nan</span></code> flag is set
45            and an attempt is made to format infinity or NaN. It would be better
46            if the facet set the <code class="computeroutput"><span class="identifier">fail</span> <span class="identifier">bit</span></code> of the stream. However, facets
47            derived from <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">num_put</span></code> do not have access to the stream
48            state.
49          </li>
50</ul></div>
51</div>
52<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
53<td align="left"></td>
54<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
55      Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
56      Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
57      Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
58      Daryle Walker and Xiaogang Zhang<p>
59        Distributed under the Boost Software License, Version 1.0. (See accompanying
60        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>)
61      </p>
62</div></td>
63</tr></table>
64<hr>
65<div class="spirit-nav">
66<a accesskey="p" href="portability.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../fp_facets.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="../next_float.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
67</div>
68</body>
69</html>
70