summaryrefslogtreecommitdiff
path: root/libs/fusion/doc/html/fusion/notes.html
blob: 738e0dcbd9a9ee7dec626972bec7e33a7de3a31b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Notes</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Fusion 2.2">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Fusion 2.2">
<link rel="prev" href="functional/generation/metafunctions/mk_unfused.html" title="make_unfused">
<link rel="next" href="change_log.html" title="Change log">
</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="functional/generation/metafunctions/mk_unfused.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="change_log.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="fusion.notes"></a><a class="link" href="notes.html" title="Notes">Notes</a>
</h2></div></div></div>
<h4>
<a name="fusion.notes.h0"></a>
      <span class="phrase"><a name="fusion.notes.recursive_inlined_functions"></a></span><a class="link" href="notes.html#fusion.notes.recursive_inlined_functions">Recursive
      Inlined Functions</a>
    </h4>
<p>
      An interesting peculiarity of functions like <a class="link" href="sequence/intrinsic/functions/at.html" title="at"><code class="computeroutput"><span class="identifier">at</span></code></a> when applied to a <a class="link" href="sequence/concepts/forward_sequence.html" title="Forward Sequence">Forward
      Sequence</a> like <a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a>
      is that what could have been linear runtime complexity effectively becomes
      constant O(1) due to compiler optimization of C++ inlined functions, however
      deeply recursive (up to a certain compiler limit of course). Compile time complexity
      remains linear.
    </p>
<h4>
<a name="fusion.notes.h1"></a>
      <span class="phrase"><a name="fusion.notes.overloaded_functions"></a></span><a class="link" href="notes.html#fusion.notes.overloaded_functions">Overloaded
      Functions</a>
    </h4>
<p>
      Associative sequences use function overloading to implement membership testing
      and type associated key lookup. This amounts to constant runtime and amortized
      constant compile time complexities. There is an overloaded function, <code class="computeroutput"><span class="identifier">f</span><span class="special">(</span><span class="identifier">k</span><span class="special">)</span></code>, for each key <span class="emphasis"><em>type</em></span> <code class="computeroutput"><span class="identifier">k</span></code>. The compiler chooses the appropriate function
      given a key, <code class="computeroutput"><span class="identifier">k</span></code>.
    </p>
<h4>
<a name="fusion.notes.h2"></a>
      <span class="phrase"><a name="fusion.notes.tag_dispatching"></a></span><a class="link" href="notes.html#fusion.notes.tag_dispatching">Tag
      Dispatching</a>
    </h4>
<p>
      Tag dispatching is a generic programming technique for selecting template specializations.
      There are typically 3 components involved in the tag dispatching mechanism:
    </p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
          A type for which an appropriate template specialization is required
        </li>
<li class="listitem">
          A metafunction that associates the type with a tag type
        </li>
<li class="listitem">
          A template that is specialized for the tag type
        </li>
</ol></div>
<p>
      For example, the fusion <code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">begin</span></code> metafunction
      is implemented as follows:
    </p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sequence</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">begin</span>
<span class="special">{</span>
    <span class="keyword">typedef</span> <span class="keyword">typename</span>
        <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">begin_impl</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">traits</span><span class="special">::</span><span class="identifier">tag_of</span><span class="special">&lt;</span><span class="identifier">Sequence</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&gt;::</span>
        <span class="keyword">template</span> <span class="identifier">apply</span><span class="special">&lt;</span><span class="identifier">Sequence</span><span class="special">&gt;::</span><span class="identifier">type</span>
    <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
</pre>
<p>
      In the case:
    </p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
          <code class="computeroutput"><span class="identifier">Sequence</span></code> is the type for
          which a suitable implementation of <code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">begin_impl</span></code>
          is required
        </li>
<li class="listitem">
          <code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">tag_of</span></code> is the metafunction that associates
          <code class="computeroutput"><span class="identifier">Sequence</span></code> with an appropriate
          tag
        </li>
<li class="listitem">
          <code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">begin_impl</span></code> is the template which is specialized
          to provide an implementation for each tag type
        </li>
</ol></div>
<h4>
<a name="fusion.notes.h3"></a>
      <span class="phrase"><a name="fusion.notes.extensibility"></a></span><a class="link" href="notes.html#fusion.notes.extensibility">Extensibility</a>
    </h4>
<p>
      Unlike <a href="http://www.boost.org/libs/mpl/index.html" target="_top">MPL</a>, there
      is no extensible sequence concept in fusion. This does not mean that Fusion
      sequences are not extensible. In fact, all Fusion sequences are inherently
      extensible. It is just that the manner of sequence extension in Fusion is different
      from both <a href="http://en.wikipedia.org/wiki/Standard_Template_Library" target="_top">STL</a>
      and <a href="http://www.boost.org/libs/mpl/index.html" target="_top">MPL</a> on account
      of the lazy nature of fusion <a class="link" href="algorithm.html" title="Algorithm">Algorithms</a>.
      <a href="http://en.wikipedia.org/wiki/Standard_Template_Library" target="_top">STL</a>
      containers extend themselves in place though member functions such as <a class="link" href="algorithm/transformation/functions/push_back.html" title="push_back"><code class="computeroutput"><span class="identifier">push_back</span></code></a> and <a class="link" href="algorithm/transformation/functions/insert.html" title="insert"><code class="computeroutput"><span class="identifier">insert</span></code></a>. <a href="http://www.boost.org/libs/mpl/index.html" target="_top">MPL</a>
      sequences, on the other hand, are extended through "intrinsic" functions
      that actually return whole sequences. <a href="http://www.boost.org/libs/mpl/index.html" target="_top">MPL</a>
      is purely functional and can not have side effects. For example, <a href="http://www.boost.org/libs/mpl/index.html" target="_top">MPL</a>'s
      <code class="computeroutput"><span class="identifier">push_back</span></code> does not actually
      mutate an <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">vector</span></code>. It can't do that. Instead, it returns
      an extended <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">vector</span></code>.
    </p>
<p>
      Like <a href="http://www.boost.org/libs/mpl/index.html" target="_top">MPL</a>, Fusion
      too is purely functional and can not have side effects. With runtime efficiency
      in mind, Fusion sequences are extended through generic functions that return
      <a class="link" href="view.html" title="View">Views</a>. <a class="link" href="view.html" title="View">Views</a>
      are sequences that do not actually contain data, but instead impart an alternative
      presentation over the data from one or more underlying sequences. <a class="link" href="view.html" title="View">Views</a>
      are proxies. They provide an efficient yet purely functional way to work on
      potentially expensive sequence operations. For example, given a <a class="link" href="container/vector.html" title="vector"><code class="computeroutput"><span class="identifier">vector</span></code></a>, Fusion's <a class="link" href="algorithm/transformation/functions/push_back.html" title="push_back"><code class="computeroutput"><span class="identifier">push_back</span></code></a> returns a <a class="link" href="view/joint_view.html" title="joint_view"><code class="computeroutput"><span class="identifier">joint_view</span></code></a>, instead of an actual extended
      <a class="link" href="container/vector.html" title="vector"><code class="computeroutput"><span class="identifier">vector</span></code></a>.
      A <a class="link" href="view/joint_view.html" title="joint_view"><code class="computeroutput"><span class="identifier">joint_view</span></code></a>
      holds a reference to the original sequence plus the appended data --making
      it very cheap to pass around.
    </p>
<h4>
<a name="fusion.notes.h4"></a>
      <span class="phrase"><a name="fusion.notes.element_conversion"></a></span><a class="link" href="notes.html#fusion.notes.element_conversion">Element
      Conversion</a>
    </h4>
<p>
      Functions that take in elemental values to form sequences (e.g. <a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a>) convert their arguments
      to something suitable to be stored as a sequence element. In general, the element
      types are stored as plain values. Example:
    </p>
<pre class="programlisting"><a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="char">'x'</span><span class="special">)</span>
</pre>
<p>
      returns a <a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a><code class="computeroutput"><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span>
      <span class="keyword">char</span><span class="special">&gt;</span></code>.
    </p>
<p>
      There are a few exceptions, however.
    </p>
<p>
      <span class="bold"><strong>Arrays:</strong></span>
    </p>
<p>
      Array arguments are deduced to reference to const types. For example <a href="#ftn.fusion.notes.f0" class="footnote" name="fusion.notes.f0"><sup class="footnote">[14]</sup></a>:
    </p>
<pre class="programlisting"><a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(</span><span class="string">"Donald"</span><span class="special">,</span> <span class="string">"Daisy"</span><span class="special">)</span>
</pre>
<p>
      creates a <a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a>
      of type
    </p>
<pre class="programlisting"><a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span> <span class="special">(&amp;)[</span><span class="number">7</span><span class="special">],</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">(&amp;)[</span><span class="number">6</span><span class="special">]&gt;</span>
</pre>
<p>
      <span class="bold"><strong>Function pointers:</strong></span>
    </p>
<p>
      Function pointers are deduced to the plain non-reference type (i.e. to plain
      function pointer). Example:
    </p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">);</span>
  <span class="special">...</span>
<a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(&amp;</span><span class="identifier">f</span><span class="special">);</span>
</pre>
<p>
      creates a <a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a>
      of type
    </p>
<pre class="programlisting"><a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a><span class="special">&lt;</span><span class="keyword">void</span> <span class="special">(*)(</span><span class="keyword">int</span><span class="special">)&gt;</span>
</pre>
<h4>
<a name="fusion.notes.h5"></a>
      <span class="phrase"><a name="fusion.notes.reference_wrappers"></a></span><a class="link" href="notes.html#fusion.notes.reference_wrappers">Reference
      Wrappers</a>
    </h4>
<p>
      Fusion's generation functions (e.g. <a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a>) by default stores the element
      types as plain non-reference types. Example:
    </p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">B</span><span class="special">&amp;</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">{</span>
    <span class="special">...</span>
    <a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span>
</pre>
<p>
      creates a <a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a>
      of type
    </p>
<pre class="programlisting"><a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">&gt;</span>
</pre>
<p>
      Sometimes the plain non-reference type is not desired. You can use <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span></code>
      and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">cref</span></code> to store references or const references
      (respectively) instead. The mechanism does not compromise const correctness
      since a const object wrapped with ref results in a tuple element with const
      reference type (see the fifth code line below). Examples:
    </p>
<p>
      For example:
    </p>
<pre class="programlisting"><span class="identifier">A</span> <span class="identifier">a</span><span class="special">;</span> <span class="identifier">B</span> <span class="identifier">b</span><span class="special">;</span> <span class="keyword">const</span> <span class="identifier">A</span> <span class="identifier">ca</span> <span class="special">=</span> <span class="identifier">a</span><span class="special">;</span>
<a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(</span><span class="identifier">cref</span><span class="special">(</span><span class="identifier">a</span><span class="special">),</span> <span class="identifier">b</span><span class="special">);</span>          <span class="comment">// creates list&lt;const A&amp;, B&gt;</span>
<a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(</span><span class="identifier">ref</span><span class="special">(</span><span class="identifier">a</span><span class="special">),</span> <span class="identifier">b</span><span class="special">);</span>           <span class="comment">// creates list&lt;A&amp;, B&gt;</span>
<a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(</span><span class="identifier">ref</span><span class="special">(</span><span class="identifier">a</span><span class="special">),</span> <span class="identifier">cref</span><span class="special">(</span><span class="identifier">b</span><span class="special">));</span>     <span class="comment">// creates list&lt;A&amp;, const B&amp;&gt;</span>
<a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(</span><span class="identifier">cref</span><span class="special">(</span><span class="identifier">ca</span><span class="special">));</span>            <span class="comment">// creates list&lt;const A&amp;&gt;</span>
<a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a><span class="special">(</span><span class="identifier">ref</span><span class="special">(</span><span class="identifier">ca</span><span class="special">));</span>             <span class="comment">// creates list&lt;const A&amp;&gt;</span>
</pre>
<p>
      See <a href="http://www.boost.org/doc/html/ref.html" target="_top">Boost.Ref</a> for
      details.
    </p>
<p>
      Since C++11, the standard reference wrappers (<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ref</span></code> and
      <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cref</span></code>) work as well.
    </p>
<h4>
<a name="fusion.notes.h6"></a>
      <span class="phrase"><a name="fusion.notes.adt_attribute_proxy"></a></span><a class="link" href="notes.html#fusion.notes.adt_attribute_proxy">adt_attribute_proxy</a>
    </h4>
<p>
      To adapt arbitrary data types that do not allow direct access to their members,
      but allow indirect access via expressions (such as invocations of get- and
      set-methods), fusion's <code class="literal">BOOST_FUSION_ADAPT_<span class="emphasis"><em>xxx</em></span>ADT<span class="emphasis"><em>xxx</em></span></code>-family
      (e.g. <a class="link" href="adapted/adapt_adt.html" title="BOOST_FUSION_ADAPT_ADT"><code class="computeroutput"><span class="identifier">BOOST_FUSION_ADAPT_ADT</span></code></a>)
      may be used. To bypass the restriction of not having actual lvalues that represent
      the elements of the fusion sequence, but rather a sequence of paired expressions
      that access the elements, the actual return type of fusion's intrinsic sequence
      access functions (<a class="link" href="sequence/intrinsic/functions/at.html" title="at"><code class="computeroutput"><span class="identifier">at</span></code></a>, <a class="link" href="sequence/intrinsic/functions/at_c.html" title="at_c"><code class="computeroutput"><span class="identifier">at_c</span></code></a>, <a class="link" href="sequence/intrinsic/functions/at_key.html" title="at_key"><code class="computeroutput"><span class="identifier">at_key</span></code></a>, <a class="link" href="iterator/functions/deref.html" title="deref"><code class="computeroutput"><span class="identifier">deref</span></code></a>, and <a class="link" href="iterator/functions/deref_data.html" title="deref_data"><code class="computeroutput"><span class="identifier">deref_data</span></code></a>) is a proxy type, an instance
      of <code class="computeroutput"><span class="identifier">adt_attribute_proxy</span></code>, that
      encapsulates these expressions.
    </p>
<p>
      <code class="computeroutput"><span class="identifier">adt_attribute_proxy</span></code> is defined
      in the namespace <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">fusion</span><span class="special">::</span><span class="identifier">extension</span></code> and has three template arguments:
    </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">fusion</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">extension</span>
<span class="special">{</span>
    <span class="keyword">template</span><span class="special">&lt;</span>
        <span class="keyword">typename</span> <span class="identifier">Type</span>
      <span class="special">,</span> <span class="keyword">int</span> <span class="identifier">Index</span>
      <span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">Const</span>
    <span class="special">&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">adt_attribute_proxy</span><span class="special">;</span>
<span class="special">}}}</span>
</pre>
<p>
      When adapting a class type, <code class="computeroutput"><span class="identifier">adt_attribute_proxy</span></code>
      is specialized for every element of the adapted sequence, with <code class="computeroutput"><span class="identifier">Type</span></code> being the class type that is adapted,
      <code class="computeroutput"><span class="identifier">Index</span></code> the 0-based indices of
      the elements, and <code class="computeroutput"><span class="identifier">Const</span></code> both
      <code class="computeroutput"><span class="keyword">true</span></code> and <code class="computeroutput"><span class="keyword">false</span></code>.
      The return type of fusion's intrinsic sequence access functions for the <span class="emphasis"><em>N</em></span>th
      element of an adapted class type <code class="computeroutput"><span class="identifier">type_name</span></code>
      is <code class="literal">adt_attribute_proxy&lt;type_name, <span class="emphasis"><em>N</em></span>, <span class="emphasis"><em>Const</em></span>&gt;</code>,
      with <code class="literal"><span class="emphasis"><em>Const</em></span></code> being <code class="computeroutput"><span class="keyword">true</span></code>
      for constant instances of <code class="computeroutput"><span class="identifier">type_name</span></code>
      and <code class="computeroutput"><span class="keyword">false</span></code> for non-constant ones.
    </p>
<div class="variablelist">
<p class="title"><b>Notation</b></p>
<dl class="variablelist">
<dt><span class="term"><code class="computeroutput"><span class="identifier">type_name</span></code></span></dt>
<dd><p>
            The type to be adapted, with M attributes
          </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">inst</span></code></span></dt>
<dd><p>
            Object of type <code class="computeroutput"><span class="identifier">type_name</span></code>
          </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">const_inst</span></code></span></dt>
<dd><p>
            Object of type <code class="computeroutput"><span class="identifier">type_name</span> <span class="keyword">const</span></code>
          </p></dd>
<dt><span class="term"><code class="literal">(attribute_type<span class="emphasis"><em>N</em></span>, attribute_const_type<span class="emphasis"><em>N</em></span>,
        get_expr<span class="emphasis"><em>N</em></span>, set_expr<span class="emphasis"><em>N</em></span>)</code></span></dt>
<dd><p>
            Attribute descriptor of the <span class="emphasis"><em>N</em></span>th attribute of <code class="computeroutput"><span class="identifier">type_name</span></code> as passed to the adaption
            macro, 0&#8804;<span class="emphasis"><em>N</em></span>&lt;M
          </p></dd>
<dt><span class="term"><code class="literal">proxy_type<span class="emphasis"><em>N</em></span></code></span></dt>
<dd><p>
            <code class="literal">adt_attribute_proxy&lt;type_name, <span class="emphasis"><em>N</em></span>, <code class="computeroutput"><span class="keyword">false</span></code>&gt;</code> with <span class="emphasis"><em>N</em></span>
            being an integral constant, 0&#8804;<span class="emphasis"><em>N</em></span>&lt;M
          </p></dd>
<dt><span class="term"><code class="literal">const_proxy_type<span class="emphasis"><em>N</em></span></code></span></dt>
<dd><p>
            <code class="literal">adt_attribute_proxy&lt;type_name, <span class="emphasis"><em>N</em></span>, <code class="computeroutput"><span class="keyword">true</span></code>&gt;</code> with <span class="emphasis"><em>N</em></span>
            being an integral constant, 0&#8804;<span class="emphasis"><em>N</em></span>&lt;M
          </p></dd>
<dt><span class="term"><code class="literal">proxy<span class="emphasis"><em>N</em></span></code></span></dt>
<dd><p>
            Object of type <code class="literal">proxy_type<span class="emphasis"><em>N</em></span></code>
          </p></dd>
<dt><span class="term"><code class="literal">const_proxy<span class="emphasis"><em>N</em></span></code></span></dt>
<dd><p>
            Object of type <code class="literal">const_proxy_type<span class="emphasis"><em>N</em></span></code>
          </p></dd>
</dl>
</div>
<p>
      <span class="bold"><strong>Expression Semantics</strong></span>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Expression
              </p>
            </th>
<th>
              <p>
                Semantics
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                <code class="literal">proxy_type<span class="emphasis"><em>N</em></span>(inst)</code>
              </p>
            </td>
<td>
              <p>
                Creates an instance of <code class="literal">proxy_type<span class="emphasis"><em>N</em></span></code>
                with underlying object <code class="computeroutput"><span class="identifier">inst</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="literal">const_proxy_type<span class="emphasis"><em>N</em></span>(const_inst)</code>
              </p>
            </td>
<td>
              <p>
                Creates an instance of <code class="literal">const_proxy_type<span class="emphasis"><em>N</em></span></code>
                with underlying object <code class="computeroutput"><span class="identifier">const_inst</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="literal">proxy_type<span class="emphasis"><em>N</em></span>::type</code>
              </p>
            </td>
<td>
              <p>
                Another name for <code class="literal">attribute_type<span class="emphasis"><em>N</em></span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="literal">const_proxy_type<span class="emphasis"><em>N</em></span>::type</code>
              </p>
            </td>
<td>
              <p>
                Another name for <code class="literal">const_attribute_type<span class="emphasis"><em>N</em></span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="literal">proxy<span class="emphasis"><em>N</em></span>=t</code>
              </p>
            </td>
<td>
              <p>
                Invokes <code class="literal">set_expr<span class="emphasis"><em>N</em></span></code>, with
                <code class="computeroutput"><span class="identifier">t</span></code> being an arbitrary
                object. <code class="literal">set_expr<span class="emphasis"><em>N</em></span></code> may access
                the variables named <code class="computeroutput"><span class="identifier">obj</span></code>
                of type <code class="computeroutput"><span class="identifier">type_name</span><span class="special">&amp;</span></code>, which represent the corresponding
                instance of <code class="computeroutput"><span class="identifier">type_name</span></code>,
                and <code class="computeroutput"><span class="identifier">val</span></code> of an arbitrary
                const-qualified reference template type parameter <code class="computeroutput"><span class="identifier">Val</span></code>,
                which represents <code class="computeroutput"><span class="identifier">t</span></code>.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="literal">proxy<span class="emphasis"><em>N</em></span>.get()</code>
              </p>
            </td>
<td>
              <p>
                Invokes <code class="literal">get_expr<span class="emphasis"><em>N</em></span></code> and forwards
                its return value. <code class="literal">get_expr<span class="emphasis"><em>N</em></span></code>
                may access the variable named <code class="computeroutput"><span class="identifier">obj</span></code>
                of type <code class="computeroutput"><span class="identifier">type_name</span><span class="special">&amp;</span></code> which represents the underlying
                instance of <code class="computeroutput"><span class="identifier">type_name</span></code>.
                <code class="literal">attribute_type<span class="emphasis"><em>N</em></span></code> may specify
                the type that <code class="literal">get_expr<span class="emphasis"><em>N</em></span></code> denotes
                to.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="literal">const_proxy<span class="emphasis"><em>N</em></span>.get()</code>
              </p>
            </td>
<td>
              <p>
                Invokes <code class="literal">get_expr<span class="emphasis"><em>N</em></span></code> and forwards
                its return value. <code class="literal">get_expr<span class="emphasis"><em>N</em></span></code>
                may access the variable named <code class="computeroutput"><span class="identifier">obj</span></code>
                of type <code class="computeroutput"><span class="identifier">type_name</span> <span class="keyword">const</span><span class="special">&amp;</span></code>
                which represents the underlying instance of <code class="computeroutput"><span class="identifier">type_name</span></code>.
                <code class="literal">attribute_const_type<span class="emphasis"><em>N</em></span></code> may
                specify the type that <code class="literal">get_expr<span class="emphasis"><em>N</em></span></code>
                denotes to.
              </p>
            </td>
</tr>
</tbody>
</table></div>
<p>
      Additionally, <code class="literal">proxy_type<span class="emphasis"><em>N</em></span></code> and <code class="literal">const_proxy_type<span class="emphasis"><em>N</em></span></code>
      are copy constructible, copy assignable and implicitly convertible to <code class="literal">proxy_type<span class="emphasis"><em>N</em></span>::type</code>
      or <code class="literal">const_proxy_type<span class="emphasis"><em>N</em></span>::type</code>.
    </p>
<div class="tip"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../doc/src/images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>
        To avoid the pitfalls of the proxy type, an arbitrary class type may also
        be adapted directly using fusion's <a class="link" href="extension.html" title="Extension">intrinsic
        extension mechanism</a>.
      </p></td></tr>
</table></div>
<div class="footnotes">
<br><hr style="width:100; text-align:left;margin-left: 0">
<div id="ftn.fusion.notes.f0" class="footnote"><p><a href="#fusion.notes.f0" class="para"><sup class="para">[14] </sup></a>
        Note that the type of a string literal is an array of const characters, not
        <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span></code>. To get <a class="link" href="container/generation/functions/make_list.html" title="make_list"><code class="computeroutput"><span class="identifier">make_list</span></code></a> to create a <a class="link" href="container/list.html" title="list"><code class="computeroutput"><span class="identifier">list</span></code></a> with an element of a non-const
        array type one must use the <code class="computeroutput"><span class="identifier">ref</span></code>
        wrapper (see <a class="link" href="notes.html#fusion.notes.reference_wrappers"><code class="computeroutput"><span class="identifier">Reference</span> <span class="identifier">Wrappers</span></code></a>).
      </p></div>
</div>
</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; 2001-2006, 2011, 2012 Joel de Guzman,
      Dan Marsden, Tobias Schwinger<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="functional/generation/metafunctions/mk_unfused.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="change_log.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>