Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / convert / doc / html / boost / make_default.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Function template make_default</title>
5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.Convert 2.0">
8 <link rel="up" href="../header/boost/make_default_hpp.html" title="Header &lt;boost/make_default.hpp&gt;">
9 <link rel="prev" href="../header/boost/make_default_hpp.html" title="Header &lt;boost/make_default.hpp&gt;">
10 <link rel="next" href="../index/s18.html" title="Index">
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="../header/boost/make_default_hpp.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../header/boost/make_default_hpp.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="../index/s18.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="refentry">
26 <a name="boost.make_default"></a><div class="titlepage"></div>
27 <div class="refnamediv">
28 <h2><span class="refentrytitle">Function template make_default</span></h2>
29 <p>boost::make_default</p>
30 </div>
31 <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32 <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../header/boost/make_default_hpp.html" title="Header &lt;boost/make_default.hpp&gt;">boost/make_default.hpp</a>&gt;
33
34 </span>
35 <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="identifier">T</span> <span class="identifier">make_default</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></div>
36 <div class="refsect1">
37 <a name="idm46230273036848"></a><h2>Description</h2>
38 <p>A considerable number of libraries require an instance of a class provided (storage created and initialized). For example, </p>
39 <pre class="programlisting"><span class="identifier">Type</span> <span class="identifier">result</span><span class="special">;</span>
40 <span class="special">...</span>
41 <span class="identifier">istream</span> <span class="special">&gt;&gt;</span> <span class="identifier">result</span><span class="special">;</span>
42 </pre>
43 <p> In generic code that results in the Default Constructibility requirement imposed on every type 'Type' to be used with the respective code. Inevitably, that requirement a) either excludes all the classes that for various reasons do not meet that requirement or b) imposes certain (not necessarily desirable) design/implementation onto respective classes.</p>
44 <p>Deployment of boost::make_default() eliminates the Default Constructibility requirement with </p>
45 <pre class="programlisting"><span class="identifier">Type</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_default</span><span class="special">&lt;</span><span class="identifier">Type</span><span class="special">&gt;</span><span class="special">(</span><span class="special">)</span><span class="special">;</span>
46 <span class="special">...</span>
47 <span class="identifier">istream</span> <span class="special">&gt;&gt;</span> <span class="identifier">result</span><span class="special">;</span>
48 </pre>
49 <p> Classes with no default constructor can now be included via a boost::make_default() specialization: </p>
50 <pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
51 <span class="special">{</span>
52     <span class="keyword">template</span><span class="special">&lt;</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">Type</span> <span class="identifier">make_default</span><span class="special">&lt;</span><span class="identifier">Type</span><span class="special">&gt;</span><span class="special">(</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">Type</span><span class="special">(</span><span class="identifier">parameters</span><span class="special">)</span><span class="special">;</span> <span class="special">}</span>
53 <span class="special">}</span>
54 </pre>
55 <p> </p>
56 </div>
57 </div>
58 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
59 <td align="left"></td>
60 <td align="right"><div class="copyright-footer">Copyright &#169; 2009-2016 Vladimir Batov<p>
61         Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>.
62       </p>
63 </div></td>
64 </tr></table>
65 <hr>
66 <div class="spirit-nav">
67 <a accesskey="p" href="../header/boost/make_default_hpp.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../header/boost/make_default_hpp.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="../index/s18.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
68 </div>
69 </body>
70 </html>