]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/function_types/doc/html/boost_functiontypes/rationale.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / function_types / doc / html / boost_functiontypes / rationale.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Rationale</title>
5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.FunctionTypes 2.5">
8 <link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.FunctionTypes 2.5">
9 <link rel="prev" href="reference/macros.html" title="Macros">
10 <link rel="next" href="acknowledgements.html" title="Acknowledgements">
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="reference/macros.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.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="acknowledgements.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
27 <a name="boost_functiontypes.rationale"></a><a class="link" href="rationale.html" title="Rationale">Rationale</a>
28 </h2></div></div></div>
29 <a name="boost_functiontypes.rationale.error_handling_rationale"></a><h4>
30 <a name="boost_functiontypes.rationale.error_handling_rationale-heading"></a>
31 <a class="link" href="rationale.html#boost_functiontypes.rationale.error_handling_rationale">Error
32 handling rationale</a>
33 </h4>
34 <p>
35 The library does not define the required members of class templates in case
36 of an error. This technique causes the compiler to stop displaying diagnostics
37 in client code, at the point where the error actually is, instead of tracing
38 template instantiations into the implementation of the library.
39 </p>
40 <p>
41 The library's components have limited error conditions, so problematic input
42 can be spotted easily.
43 </p>
44 <a name="boost_functiontypes.rationale.why_mpl_sequences_"></a><h4>
45 <a name="boost_functiontypes.rationale.why_mpl_sequences_-heading"></a>
46 <a class="link" href="rationale.html#boost_functiontypes.rationale.why_mpl_sequences_">Why MPL Sequences?</a>
47 </h4>
48 <p>
49 MPL provides algorithms on Sequences, so transformations (such as turning by-value
50 parameter types into const references for optimized forwarding or computing
51 a signature to specialize <a href="../../../../function/index.html" target="_top"><code class="literal">boost::function</code></a>
52 after applying <a href="../../../../bind/index.html" target="_top"><code class="literal">boost::bind</code></a>)
53 can be expressed more easily. The MPL Sequence concept is compatible with several
54 other Boost libraries (most importantly <a href="../../../../fusion/index.html" target="_top">Fusion</a>),
55 so another reason is interoperability.
56 </p>
57 <a name="boost_functiontypes.rationale.pointer_to_member_object_types"></a><h4>
58 <a name="boost_functiontypes.rationale.pointer_to_member_object_types-heading"></a>
59 <a class="link" href="rationale.html#boost_functiontypes.rationale.pointer_to_member_object_types">Pointer
60 to member object types</a>
61 </h4>
62 <p>
63 Despite their syntax, pointer to member object types can be seen as dereferencing
64 functionals.
65 </p>
66 <a name="boost_functiontypes.rationale.the_classtransform_template_parameter"></a><h4>
67 <a name="boost_functiontypes.rationale.the_classtransform_template_parameter-heading"></a>
68 <a class="link" href="rationale.html#boost_functiontypes.rationale.the_classtransform_template_parameter">The
69 ClassTransform template parameter</a>
70 </h4>
71 <p>
72 <code class="literal">This</code>-pointer, <code class="literal">this</code>-reference or just
73 the object (or maybe even a smart pointer to the object) plus adjustments of
74 cv-qualification - all these cases have their place, somewhere and there is
75 no single best answer.
76 </p>
77 <p>
78 Special treatment of the class type within the sequence can significantly complicate
79 client code. A custom <code class="literal">ClassTransform</code> argument allows the
80 client to adjust the class type before the sequence is formed and then treat
81 all parameters uniformly.
82 </p>
83 <a name="boost_functiontypes.rationale.why_tag_types_"></a><h4>
84 <a name="boost_functiontypes.rationale.why_tag_types_-heading"></a>
85 <a class="link" href="rationale.html#boost_functiontypes.rationale.why_tag_types_">Why tag types?</a>
86 </h4>
87 <p>
88 Let's consider the alternatives.
89 </p>
90 <p>
91 The first one is just using more templates so every property has to be asked
92 for explicitly. This approach results in more complicated client code if more
93 than one propery has to be checked and in a exponentially larger library interface.
94 </p>
95 <p>
96 The second alternative is having the client pass in bit patterns via non-type
97 template parameters. The logic has to be performed by the client and there
98 are much more error conditions. Further, class templates with non-type template
99 parameters do not work within MPL lambda expressions and can cause problems
100 with older compilers.
101 </p>
102 <a name="boost_functiontypes.rationale.is_it_safe_to_have_the_synthesis_templates_take_a_callable__builtin_type_or_an_mpl_sequence_as_the_first_template_argument_"></a><h4>
103 <a name="boost_functiontypes.rationale.is_it_safe_to_have_the_synthesis_templates_take_a_callable__builtin_type_or_an_mpl_sequence_as_the_first_template_argument_-heading"></a>
104 <a class="link" href="rationale.html#boost_functiontypes.rationale.is_it_safe_to_have_the_synthesis_templates_take_a_callable__builtin_type_or_an_mpl_sequence_as_the_first_template_argument_">Is
105 it safe to have the synthesis templates take a callable builtin type or an
106 MPL sequence as the first template argument?</a>
107 </h4>
108 <p>
109 Yes, but it isn't immediately obvious as the set of possible MPL sequences
110 isn't inherently disjoint from the set of callable builtin types.
111 </p>
112 <p>
113 However, any attempt to make a builtin type work as an MPL sequence is a bad
114 idea, because builtin types are accessible before the headers that make the
115 type a sequence have been included, which can easily violate the ODR.
116 </p>
117 <a name="boost_functiontypes.rationale.why_does_the_hidden__literal_this__literal__parameter_count_for_the__function_arity_of_member_functions_"></a><h4>
118 <a name="boost_functiontypes.rationale.why_does_the_hidden__literal_this__literal__parameter_count_for_the__function_arity_of_member_functions_-heading"></a>
119 <a class="link" href="rationale.html#boost_functiontypes.rationale.why_does_the_hidden__literal_this__literal__parameter_count_for_the__function_arity_of_member_functions_">Why
120 does the hidden <code class="literal">this</code> parameter count for the function arity
121 of member functions?</a>
122 </h4>
123 <p>
124 It was found preferable that the following condition holds:
125 </p>
126 <pre class="programlisting"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">size</span><span class="special">&lt;</span> <a class="link" href="reference/decomposition.html#boost_functiontypes.reference.decomposition.parameter_types" title="parameter_types">parameter_types</a><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">==</span> <a class="link" href="reference/decomposition.html#boost_functiontypes.reference.decomposition.function_arity" title="function_arity">function_arity</a><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">value</span>
127 </pre>
128 <a name="boost_functiontypes.rationale.why_ignore_top_level_cv_qualifiers_on_pointers_"></a><h4>
129 <a name="boost_functiontypes.rationale.why_ignore_top_level_cv_qualifiers_on_pointers_-heading"></a>
130 <a class="link" href="rationale.html#boost_functiontypes.rationale.why_ignore_top_level_cv_qualifiers_on_pointers_">Why
131 ignore top-level cv-qualifiers on pointers?</a>
132 </h4>
133 <p>
134 A cv-qualified pointer is still a pointer. It usually doesn't matter and even
135 if it does, it's a job for <a href="../../../../type_traits/index.html" target="_top">Boost.TypeTraits</a>.
136 </p>
137 </div>
138 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
139 <td align="left"></td>
140 <td align="right"><div class="copyright-footer">Copyright &#169; 2004-2007 Tobias
141 Schwinger<p>
142 Distributed under the Boost Software License, Version 1.0. (See accompanying
143 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>)
144 </p>
145 </div></td>
146 </tr></table>
147 <hr>
148 <div class="spirit-nav">
149 <a accesskey="p" href="reference/macros.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.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="acknowledgements.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
150 </div>
151 </body>
152 </html>