]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Convert Numeric Types and Enums to double</title> | |
5 | <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css"> | |
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.77.1"> | |
7 | <link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits"> | |
8 | <link rel="up" href="../examples.html" title="Examples"> | |
9 | <link rel="prev" href="iter.html" title="An improved Version of std::iter_swap"> | |
10 | <link rel="next" href="improved_min.html" title="Improving std::min with common_type"> | |
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="iter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.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="improved_min.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="boost_typetraits.examples.to_double"></a><a class="link" href="to_double.html" title="Convert Numeric Types and Enums to double">Convert Numeric | |
28 | Types and Enums to double</a> | |
29 | </h3></div></div></div> | |
30 | <p> | |
31 | Demonstrates a conversion of <a href="../../../../../../libs/numeric/conversion/doc/html/boost_numericconversion/definitions.html#boost_numericconversion.definitions.numeric_types" target="_top">Numeric | |
32 | Types</a> and enum types to double: | |
33 | </p> | |
34 | <pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> | |
35 | <span class="keyword">inline</span> <span class="keyword">double</span> <span class="identifier">to_double</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">value</span><span class="special">)</span> | |
36 | <span class="special">{</span> | |
37 | <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">promote</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">promoted</span><span class="special">;</span> | |
38 | <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">converter</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span><span class="identifier">promoted</span><span class="special">>::</span><span class="identifier">convert</span><span class="special">(</span><span class="identifier">value</span><span class="special">);</span> | |
39 | <span class="special">}</span> | |
40 | </pre> | |
41 | </div> | |
42 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
43 | <td align="left"></td> | |
44 | <td align="right"><div class="copyright-footer">Copyright © 2000, 2011 Adobe Systems Inc, David Abrahams, | |
45 | Frederic Bron, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, | |
46 | Jesse Jones, Mat Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten | |
47 | Ottosen, Roman Perepelitsa, Robert Ramey, Jeremy Siek, Robert Stewart and Steven | |
48 | Watanabe<p> | |
49 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
50 | 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>) | |
51 | </p> | |
52 | </div></td> | |
53 | </tr></table> | |
54 | <hr> | |
55 | <div class="spirit-nav"> | |
56 | <a accesskey="p" href="iter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.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="improved_min.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> | |
57 | </div> | |
58 | </body> | |
59 | </html> |