]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/doc/adapted.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / fusion / doc / adapted.qbk
1 [/==============================================================================
2 Copyright (C) 2001-2011 Joel de Guzman
3 Copyright (C) 2006 Dan Marsden
4 Copyright (C) 2010 Christopher Schmidt
5
6 Use, modification and distribution is subject to the Boost Software
7 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 http://www.boost.org/LICENSE_1_0.txt)
9 ===============================================================================/]
10 [section Adapted]
11
12 Fusion provides a couple of adapters for other sequences such as arrays,
13 `std::pair`, __mpl__ sequences, and `boost::array`. These adapters are
14 written using Fusion's non-intrusive __extension__ mechanism. If you wish
15 to use these sequences with fusion, simply include the necessary files and
16 they will be regarded as first-class, fully conforming fusion sequences.
17
18 Fusion also provides various schemes to make it easy for the user to adapt
19 various data structures, non-intrusively, as full fledged Fusion sequences.
20
21 [heading Header]
22
23 #include <boost/fusion/adapted.hpp>
24 #include <boost/fusion/include/adapted.hpp>
25
26 Fusion sequences may also be adapted as fully conforming __mpl__ sequences (see
27 __intrinsics__). That way, we can have 2-way adaptation to and from __mpl__ and
28 Fusion. To make Fusion sequences fully conforming __mpl__ sequences, include:
29
30 #include <boost/fusion/mpl.hpp>
31
32 If you want bi-directional adaptation to and from __mpl__ and Fusion, simply
33 include:
34
35 #include <boost/fusion/include/mpl.hpp>
36
37 The header includes all the necessary headers.
38
39 [section:array Array]
40
41 This module provides adapters for arrays. Including the module
42 header makes any array a fully conforming __random_access_sequence__.
43
44 [heading Header]
45
46 #include <boost/fusion/adapted/array.hpp>
47 #include <boost/fusion/include/array.hpp>
48
49 [heading Model of]
50
51 * __random_access_sequence__
52
53 [heading Example]
54
55 int arr[3] = {1,2,3};
56
57 std::cout << *__begin__(arr) << std::endl;
58 std::cout << *__next__(__begin__(arr)) << std::endl;
59 std::cout << *__advance_c__<2>(__begin__(arr)) << std::endl;
60 std::cout << *__prior__(__end__(arr)) << std::endl;
61 std::cout << __at_c__<2>(arr) << std::endl;
62
63 [endsect]
64
65 [section std::pair]
66
67 This module provides adapters for `std::pair`. Including the module header
68 makes `std::pair` a fully conforming __random_access_sequence__.
69
70 [heading Header]
71
72 #include <boost/fusion/adapted/std_pair.hpp>
73 #include <boost/fusion/include/std_pair.hpp>
74
75 [heading Model of]
76
77 * __random_access_sequence__
78
79 [heading Example]
80
81 std::pair<int, std::string> p(123, "Hola!!!");
82 std::cout << __at_c__<0>(p) << std::endl;
83 std::cout << __at_c__<1>(p) << std::endl;
84 std::cout << p << std::endl;
85
86 [heading See also]
87
88 __std_pair_doc__, __tr1_tuple_pair__
89
90 [endsect]
91
92 [section std::tuple]
93
94 This module provides adapters for `std::tuple`. Including the module header
95 makes `std::tuple` a fully conforming __random_access_sequence__.
96
97 [important To be fully conforming, compiler should support C++11 Variadic Templates.]
98
99 [heading Header]
100
101 #include <boost/fusion/adapted/std_tuple.hpp>
102 #include <boost/fusion/include/std_tuple.hpp>
103
104 [heading Model of]
105
106 * __random_access_sequence__
107
108 [heading Example]
109
110 std::tuple<int, std::string, float> p(123, "Hola!!!", 456.f);
111 std::cout << __at_c__<0>(p) << std::endl;
112 std::cout << __at_c__<1>(p) << std::endl;
113 std::cout << p << std::endl;
114
115 [heading See also]
116
117 __std_tuple_doc__
118
119 [endsect]
120
121 [section mpl sequence]
122
123 This module provides adapters for __mpl__ sequences. Including the module
124 header makes all __mpl__ sequences fully conforming fusion sequences.
125
126 [heading Header]
127
128 #include <boost/fusion/adapted/mpl.hpp>
129 #include <boost/fusion/include/mpl.hpp>
130
131 [heading Model of]
132
133 * __forward_sequence__ (If the __mpl__ sequence is a forward sequence.)
134 * __bidirectional_sequence__ (If the __mpl__ sequence is a bidirectional sequence.)
135 * __random_access_sequence__ (If the __mpl__ sequence is a random access sequence.)
136
137 [heading Example]
138
139 mpl::vector_c<int, 123, 456> vec_c;
140 fusion::vector2<int, long> v(vec_c);
141 std::cout << __at_c__<0>(v) << std::endl;
142 std::cout << __at_c__<1>(v) << std::endl;
143
144 v = mpl::vector_c<int, 456, 789>();
145 std::cout << __at_c__<0>(v) << std::endl;
146 std::cout << __at_c__<1>(v) << std::endl;
147
148 [heading See also]
149
150 __mpl__
151
152 [endsect]
153
154 [section boost::array]
155
156 This module provides adapters for `boost::array`. Including the module
157 header makes `boost::array` a fully conforming __random_access_sequence__.
158
159 [heading Header]
160
161 #include <boost/fusion/adapted/boost_array.hpp>
162 #include <boost/fusion/include/boost_array.hpp>
163
164 [heading Model of]
165
166 * __random_access_sequence__
167
168 [heading Example]
169
170 boost::array<int,3> arr = {{1,2,3}};
171
172 std::cout << *__begin__(arr) << std::endl;
173 std::cout << *__next__(__begin__(arr)) << std::endl;
174 std::cout << *__advance_c__<2>(__begin__(arr)) << std::endl;
175 std::cout << *__prior__(__end__(arr)) << std::endl;
176 std::cout << __at_c__<2>(arr) << std::endl;
177
178 [heading See also]
179
180 __boost_array_library__
181
182 [endsect]
183
184 [section boost::tuple]
185 This module provides adapters for `boost::tuple`. Including the module
186 header makes `boost::tuple` a fully conforming __forward_sequence__.
187
188 [heading Header]
189
190 #include <boost/fusion/adapted/boost_tuple.hpp>
191 #include <boost/fusion/include/boost_tuple.hpp>
192
193 [heading Model of]
194
195 * __forward_sequence__
196
197 [heading Example]
198
199 boost::tuple<int,std::string> example_tuple(101, "hello");
200 std::cout << *__begin__(example_tuple) << '\n';
201 std::cout << *__next__(__begin__(example_tuple)) << '\n';
202
203 [heading See also]
204
205 __boost_tuple_library__
206
207 [endsect]
208
209 [section:adapt_struct BOOST_FUSION_ADAPT_STRUCT]
210
211 [heading Description]
212 BOOST_FUSION_ADAPT_STRUCT is a macro that can be used to generate all the
213 necessary boilerplate to make an arbitrary struct a model of
214 __random_access_sequence__.
215
216 [heading Synopsis]
217 BOOST_FUSION_ADAPT_STRUCT(
218 struct_name,
219 member_name0,
220 member_name1,
221 member_name2,
222 ...
223 )
224
225 // Without BOOST_PP_VARIADICS support :
226 BOOST_FUSION_ADAPT_STRUCT(
227 struct_name,
228 (member_type0, member_name0)
229 (member_type1, member_name1)
230 (auto, member_name2)
231 ...
232 )
233
234 [heading Semantics]
235
236 The above macro generates the necessary code to adapt `struct_name`
237 as a model of __random_access_sequence__.
238
239 The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)`
240 pairs declares the type and names of each of the struct members that are part of
241 the sequence.
242
243 When member_typeN is omitted or set to auto, the type is
244 infered with Boost.TypeOf.
245
246 The macro should be used at global scope, and `struct_name` should be the fully
247 namespace qualified name of the struct to be adapted.
248
249 [heading Header]
250
251 #include <boost/fusion/adapted/struct/adapt_struct.hpp>
252 #include <boost/fusion/include/adapt_struct.hpp>
253
254 [heading Example: BOOST_FUSION_ADAPT_STRUCT ]
255 namespace demo
256 {
257 struct employee
258 {
259 std::string name;
260 int age;
261 };
262 }
263
264 // demo::employee is now a Fusion sequence
265 BOOST_FUSION_ADAPT_STRUCT(
266 demo::employee,
267 name,
268 age)
269
270 // Without BOOST_PP_VARIADICS support :
271 BOOST_FUSION_ADAPT_STRUCT(
272 demo::employee,
273 (auto, name)
274 (auto, age)
275 )
276
277 [endsect]
278
279 [section:adapt_tpl_struct BOOST_FUSION_ADAPT_TPL_STRUCT]
280
281 [heading Description]
282 BOOST_FUSION_ADAPT_TPL_STRUCT is a macro that can be used to generate all the
283 necessary boilerplate to make an arbitrary template struct a model of
284 __random_access_sequence__.
285
286 [heading Synopsis]
287 BOOST_FUSION_ADAPT_TPL_STRUCT(
288 (template_param0)(template_param1)...,
289 (struct_name) (specialization_param0)(specialization_param1)...,
290 member_name0,
291 member_name1
292 ...
293 )
294
295 // Without BOOST_PP_VARIADICS support :
296 BOOST_FUSION_ADAPT_TPL_STRUCT(
297 (template_param0)(template_param1)...,
298 (struct_name) (specialization_param0)(specialization_param1)...,
299 (member_type0, member_name0)
300 (member_type1, member_name1)
301 (auto, member_name2),
302 ...
303 )
304
305 [heading Semantics]
306
307 The above macro generates the necessary code to adapt `struct_name` or an
308 arbitrary specialization of `struct_name` as a model of
309 __random_access_sequence__.
310 The sequence `(template_param0)(template_param1)...` declares the names of
311 the template type parameters used.
312 The sequence `(specialization_param0)(specialization_param1)...`
313 declares the template parameters of the actual specialization of `struct_name`
314 that is adapted as a fusion sequence.
315 The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)`
316 pairs declares the type and names of each of the struct members that are part of
317 the sequence.
318
319 When member_typeN is omitted or set to auto, the type is
320 infered with Boost.TypeOf.
321
322 The macro should be used at global scope, and `struct_name` should be the fully
323 namespace qualified name of the struct to be adapted.
324
325 [heading Header]
326
327 #include <boost/fusion/adapted/struct/adapt_struct.hpp>
328 #include <boost/fusion/include/adapt_struct.hpp>
329
330 [heading Example]
331 namespace demo
332 {
333 template<typename Name, typename Age>
334 struct employee
335 {
336 Name name;
337 Age age;
338 int employment_timestamp;
339 };
340 }
341
342 // Any instantiated demo::employee is now a Fusion sequence
343 BOOST_FUSION_ADAPT_TPL_STRUCT(
344 (Name)(Age),
345 (demo::employee) (Name)(Age),
346 (Name, name)
347 (Age, age)
348 (auto, employment_timestamp))
349
350 // Or by infering type completely
351 BOOST_FUSION_ADAPT_TPL_STRUCT(
352 (Name)(Age),
353 (demo::employee) (Name)(Age),
354 name,
355 age,
356 employment_timestamp)
357
358 [endsect]
359
360 [section:adapt_struct_named BOOST_FUSION_ADAPT_STRUCT_NAMED]
361
362 [heading Description]
363 BOOST_FUSION_ADAPT_STRUCT_NAMED and BOOST_FUSION_ADAPT_STRUCT_NAMED_NS are
364 macros that can be used to generate all the necessary boilerplate to make an
365 arbitrary struct a model of __random_access_sequence__. The given struct is
366 adapted using the given name.
367
368 [heading Synopsis]
369 BOOST_FUSION_ADAPT_STRUCT_NAMED(
370 struct_name, adapted_name,
371 member_name0,
372 member_name1,
373 member_name2,
374 ...
375 )
376
377 BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(
378 struct_name,
379 (namespace0)(namespace1)...,
380 adapted_name,
381 member_name0,
382 member_name1,
383 member_name2,
384 ...
385 )
386
387 // Without BOOST_PP_VARIADICS support :
388
389 BOOST_FUSION_ADAPT_STRUCT_NAMED(
390 struct_name, adapted_name,
391 (member_type0, member_name0)
392 (member_type1, member_name1)
393 (auto, member_name2),
394 ...
395 )
396
397 BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(
398 struct_name,
399 (namespace0)(namespace1)...,
400 adapted_name,
401 (member_type0, member_name0)
402 (member_type1, member_name1)
403 (auto, member_name2),
404 ...
405 )
406
407
408
409 [heading Semantics]
410
411 The above macros generate the necessary code to adapt `struct_name`
412 as a model of __random_access_sequence__ while using `adapted_name` as the
413 name of the adapted struct.
414 The sequence `(namespace0)(namespace1)...` declares the namespace
415 for `adapted_name`. It yields to a fully qualified name for `adapted_name` of
416 `namespace0::namespace1::... adapted_name`.
417 If an empty namespace sequence is given (that is a macro that expands to
418 nothing), the adapted view is placed in the global namespace.
419 If no namespace sequence is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_NAMED`), the
420 adapted view is placed in the namespace `boost::fusion::adapted`.
421 The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)`
422 pairs declares the type and names of each of the struct members that are part of
423 the sequence.
424
425 When member_typeN is omitted or set to auto, the type is
426 infered with Boost.TypeOf.
427
428 The macros should be used at global scope, and `struct_name` should be the fully
429 namespace qualified name of the struct to be converted.
430
431 [heading Header]
432
433 #include <boost/fusion/adapted/struct/adapt_struct_named.hpp>
434 #include <boost/fusion/include/adapt_struct_named.hpp>
435
436 [heading Example]
437 namespace demo
438 {
439 struct employee
440 {
441 std::string name;
442 int age;
443 };
444 }
445
446 // boost::fusion::adapted::adapted_employee is now a Fusion sequence
447 // referring to demo::employee
448 BOOST_FUSION_ADAPT_STRUCT_NAMED(
449 demo::employee, adapted_employee,
450 name,
451 age)
452
453 // Without BOOST_PP_VARIADICS support :
454 BOOST_FUSION_ADAPT_STRUCT_NAMED(
455 demo::employee, adapted_employee,
456 (auto, name),
457 (auto, age))
458
459 [endsect]
460
461 [section:adapt_assoc BOOST_FUSION_ADAPT_ASSOC_STRUCT]
462
463 [heading Description]
464 BOOST_FUSION_ADAPT_ASSOC_STRUCT is a macro that can be used to generate all the
465 necessary boilerplate to make an arbitrary struct a model of
466 __random_access_sequence__ and __associative_sequence__.
467
468 [heading Synopsis]
469 BOOST_FUSION_ADAPT_ASSOC_STRUCT(
470 struct_name,
471 ([member_type0,] member_name0, key_type0)
472 ([member_type1,] member_name1, key_type1)
473 ...
474 )
475
476 [heading Semantics]
477
478 The above macro generates the necessary code to adapt `struct_name`
479 as a model of __random_access_sequence__ and __associative_sequence__.
480 The sequence of `([member_typeN,] member_nameN, key_typeN)` tuples
481 declares the type, name and key type of each of the struct members
482 that are part of the sequence.
483
484 When member_typeN is omitted or set to auto, the type is
485 infered with Boost.TypeOf.
486
487 The macro should be used at global scope, and `struct_name` should be the fully
488 namespace qualified name of the struct to be adapted.
489
490 [heading Header]
491
492 #include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
493 #include <boost/fusion/include/adapt_assoc_struct.hpp>
494
495 [heading Example]
496 namespace demo
497 {
498 struct employee
499 {
500 std::string name;
501 int age;
502 };
503 }
504
505 namespace keys
506 {
507 struct name;
508 struct age;
509 }
510
511 // demo::employee is now a Fusion sequence.
512 // It is also an associative sequence with
513 // keys keys::name and keys::age present.
514 BOOST_FUSION_ADAPT_ASSOC_STRUCT(
515 demo::employee,
516 (name, keys::name)
517 (age, keys::age))
518
519 // Without BOOST_PP_VARIADICS support :
520 BOOST_FUSION_ADAPT_ASSOC_STRUCT(
521 demo::employee,
522 (auto, name, keys::name),
523 (auto, age, keys::name))
524
525 [endsect]
526
527 [section:adapt_assoc_tpl_struct BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT]
528
529 [heading Description]
530 BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT is a macro that can be used to generate all the
531 necessary boilerplate to make an arbitrary template struct a model of
532 __random_access_sequence__ and __associative_sequence__.
533
534 [heading Synopsis]
535 BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
536 (template_param0)(template_param1)...,
537 (struct_name) (specialization_param0)(specialization_param1)...,
538 ([member_type0,] member_name0, key_type0)
539 ([member_type1,] member_name1, key_type1)
540 ...
541 )
542
543 [heading Semantics]
544
545 The above macro generates the necessary code to adapt `struct_name` or an
546 arbitrary specialization of `struct_name` as a model of
547 __random_access_sequence__ and __associative_sequence__.
548 The sequence `(template_param0)(template_param1)...` declares the names of
549 the template type parameters used.
550 The sequence `(specialization_param0)(specialization_param1)...`
551 declares the template parameters of the actual specialization of `struct_name`
552 that is adapted as a fusion sequence.
553 The sequence of `([member_typeN,] member_nameN, key_typeN)`
554 tuples declares the type, name and key type of each of the struct members
555 that are part of the sequence.
556
557 When member_typeN is omitted or set to auto, the type is
558 infered with Boost.TypeOf.
559
560 The macro should be used at global scope, and `struct_name` should be the fully
561 namespace qualified name of the struct to be adapted.
562
563 [heading Header]
564
565 #include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
566 #include <boost/fusion/include/adapt_assoc_struct.hpp>
567
568 [heading Example]
569 namespace demo
570 {
571 template<typename Name, typename Age>
572 struct employee
573 {
574 Name name;
575 Age age;
576 };
577 }
578
579 namespace keys
580 {
581 struct name;
582 struct age;
583 }
584
585 // Any instantiated demo::employee is now a Fusion sequence.
586 // It is also an associative sequence with
587 // keys keys::name and keys::age present.
588 BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
589 (Name)(Age),
590 (demo::employee) (Name)(Age),
591 (name, keys::name)
592 (age, keys::age))
593
594 // Without BOOST_PP_VARIADICS support :
595 BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
596 (Name)(Age),
597 (demo::employee) (Name)(Age),
598 (Name, name, keys::name)
599 (Age, age, keys::age))
600
601 [endsect]
602
603 [section:adapt_assoc_struct_named BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED]
604
605 [heading Description]
606 BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED and BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS are
607 macros that can be used to generate all the necessary boilerplate to make an
608 arbitrary struct a model of __random_access_sequence__ and
609 __associative_sequence__. The given struct is adapted using the given name.
610
611 [heading Synopsis]
612 BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
613 struct_name, adapted_name,
614 ([member_type0,] member_name0, key_type0)
615 ([member_type1,] member_name1, key_type1)
616 ...
617 )
618
619 BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS(
620 struct_name,
621 (namespace0)(namespace1)...,
622 adapted_name,
623 ([member_type0,] member_name0, key_type0)
624 ([member_type1,] member_name1, key_type1)
625 ...
626 )
627
628 [heading Semantics]
629
630 The above macros generate the necessary code to adapt `struct_name`
631 as a model of __random_access_sequence__ and __associative_sequence__ while
632 using `adapted_name` as the name of the adapted struct.
633 The sequence `(namespace0)(namespace1)...` declares the namespace
634 for `adapted_name`. It yields to a fully qualified name for `adapted_name` of
635 `namespace0::namespace1::... adapted_name`.
636 If an empty namespace sequence is given (that is a macro that expands to
637 nothing), the adapted view is placed in the global namespace.
638 If no namespace sequence is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_ASSOC_NAMED`), the
639 adapted view is placed in the namespace `boost::fusion::adapted`.
640 The sequence of `(member_typeN, member_nameN, key_typeN)`
641 triples declares the type, name and key type of each of the struct members
642 that are part of the sequence.
643
644 When member_typeN is omitted or set to auto, the type is
645 infered with Boost.TypeOf.
646
647 The macros should be used at global scope, and `struct_name` should be the fully
648 namespace qualified name of the struct to be converted.
649
650 [heading Header]
651
652 #include <boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp>
653 #include <boost/fusion/include/adapt_assoc_struct_named.hpp>
654
655 [heading Example]
656 namespace demo
657 {
658 struct employee
659 {
660 std::string name;
661 int age;
662 };
663 }
664
665 namespace keys
666 {
667 struct name;
668 struct age;
669 }
670
671 // boost::fusion::adapted::adapted_employee is now a Fusion sequence
672 // referring to demo::employee
673 BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
674 demo::employee, adapted_employee,
675 (name, keys::name)
676 (age, keys::age))
677
678 // Without BOOST_PP_VARIADICS support :
679 BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
680 demo::employee, adapted_employee,
681 (auto, name, keys::name)
682 (auto, age, keys::age))
683
684 [endsect]
685
686 [section:adapt_adt BOOST_FUSION_ADAPT_ADT]
687
688 BOOST_FUSION_ADAPT_ADT is a macro than can be used to generate all the
689 necessary boilerplate to adapt an arbitrary class type as a model of
690 __random_access_sequence__.
691
692 [heading Synopsis]
693
694 BOOST_FUSION_ADAPT_ADT(
695 type_name,
696 ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0)
697 ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1)
698 ...
699 )
700
701 [heading Expression Semantics]
702
703 The above macro generates the necessary code to adapt `type_name`
704 as a model of __random_access_sequence__.
705 The sequence of
706 [^([attribute_type['N], attribute_const_type['N],] get_expr['N], set_expr['N])]
707 quadruples declares the types, const types, get-expressions and set-expressions
708 of the elements that are part of the adapted fusion sequence.
709 [^get_expr['N]] is the expression that is invoked to get the ['N]th element
710 of an instance of `type_name`. This expression may access a variable named
711 `obj` of type `type_name&` or `type_name const&` which represents the underlying
712 instance of `type_name`.
713 [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types
714 that [^get_expr['N]] denotes to, when omitted the type is deduced from
715 [get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for
716 variadic macros auto can be used to avoid repeating the type.
717 [^set_expr['N]] is the expression that is invoked to set the ['N]th element
718 of an instance of `type_name`. This expression may access variables named
719 `obj` of type `type_name&`, which represent the corresponding instance of
720 `type_name`, and `val` of an arbitrary const-qualified reference template type
721 parameter `Val`, which represents the right operand of the assignment
722 expression.
723
724 The actual return type of fusion's intrinsic sequence access (meta-)functions
725 when in invoked with (an instance of) `type_name` is a proxy type.
726 This type is implicitly convertible to the attribute type via [^get_expr['N]] and
727 forwards assignment to the underlying element via [^set_expr['N]].
728 The value type (that is the type returned by __result_of_value_of__,
729 __result_of_value_at__ and __result_of_value_at_c__) of the ['N]th element
730 is [^attribute_type['N]] with const-qualifier and reference removed.
731
732 The macro should be used at global scope, and `type_name` should be the fully
733 namespace qualified name of the class type to be adapted.
734
735 [heading Header]
736
737 #include <boost/fusion/adapted/adt/adapt_adt.hpp>
738 #include <boost/fusion/include/adapt_adt.hpp>
739
740 [heading Example]
741 namespace demo
742 {
743 struct employee
744 {
745 private:
746 std::string name;
747 int age;
748
749 public:
750 void set_name(std::string const& n)
751 {
752 name=n;
753 }
754
755 void set_age(int a)
756 {
757 age=a;
758 }
759
760 std::string const& get_name()const
761 {
762 return name;
763 }
764
765 int get_age()const
766 {
767 return age;
768 }
769 };
770 }
771
772 BOOST_FUSION_ADAPT_ADT(
773 demo::employee,
774 (obj.get_name(), obj.set_name(val))
775 (obj.get_age(), obj.set_age(val)))
776
777 demo::employee e;
778 front(e)="Edward Norton";
779 back(e)=41;
780 //Prints 'Edward Norton is 41 years old'
781 std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl;
782
783 [heading See also]
784
785 __adt_attribute_proxy__
786
787 [endsect]
788
789 [section:adapt_tpl_adt BOOST_FUSION_ADAPT_TPL_ADT]
790
791 BOOST_FUSION_ADAPT_TPL_ADT is a macro than can be used to generate all the
792 necessary boilerplate to adapt an arbitrary template class type as a model of
793 __random_access_sequence__.
794
795 [heading Synopsis]
796
797 BOOST_FUSION_ADAPT_TPL_ADT(
798 (template_param0)(template_param1)...,
799 (type_name) (specialization_param0)(specialization_param1)...,
800 ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0)
801 ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1)
802 ...
803 )
804
805 [heading Expression Semantics]
806
807 The above macro generates the necessary code to adapt `type_name`
808 or an arbitrary specialization of `type_name`
809 as a model of __random_access_sequence__.
810 The sequence `(template_param0)(template_param1)...` declares the names of
811 the template type parameters used.
812 The sequence `(specialization_param0)(specialization_param1)...`
813 declares the template parameters of the actual specialization of `type_name`
814 that is adapted as a fusion sequence.
815 The sequence of
816 [^(attribute_type['N], attribute_const_type['N], get_expr['N], set_expr['N])]
817 quadruples declares the types, const types, get-expressions and set-expressions
818 of the elements that are part of the adapted fusion sequence.
819 [^get_expr['N]] is the expression that is invoked to get the ['N]th element
820 of an instance of `type_name`. This expression may access a variable named
821 `obj` of type `type_name&` or `type_name const&` which represents the underlying
822 instance of `type_name`.
823 [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types
824 that [^get_expr['N]] denotes to, when omitted the type is deduced from
825 [get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for
826 variadic macros auto can be used to avoid repeating the type.
827 [^set_expr['N]] is the expression that is invoked to set the ['N]th element
828 of an instance of `type_name`. This expression may access variables named
829 `obj` of type `type_name&`, which represent the corresponding instance of
830 `type_name`, and `val` of an arbitrary const-qualified reference template type
831 parameter `Val`, which represents the right operand of the assignment
832 expression.
833
834 The actual return type of fusion's intrinsic sequence access (meta-)functions
835 when in invoked with (an instance of) `type_name` is a proxy type.
836 This type is implicitly convertible to the attribute type via [^get_expr['N]] and
837 forwards assignment to the underlying element via [^set_expr['N]].
838 The value type (that is the type returned by __result_of_value_of__,
839 __result_of_value_at__ and __result_of_value_at_c__) of the ['N]th element
840 is [^attribute_type['N]] with const-qualifier and reference removed.
841
842 The macro should be used at global scope, and `type_name` should be the fully
843 namespace qualified name of the template class type to be adapted.
844
845 [heading Header]
846
847 #include <boost/fusion/adapted/adt/adapt_adt.hpp>
848 #include <boost/fusion/include/adapt_adt.hpp>
849
850 [heading Example]
851 namespace demo
852 {
853 template<typename Name, typename Age>
854 struct employee
855 {
856 private:
857 Name name;
858 Age age;
859
860 public:
861 void set_name(Name const& n)
862 {
863 name=n;
864 }
865
866 void set_age(Age const& a)
867 {
868 age=a;
869 }
870
871 Name const& get_name()const
872 {
873 return name;
874 }
875
876 Age const& get_age()const
877 {
878 return age;
879 }
880 };
881 }
882
883 BOOST_FUSION_ADAPT_TPL_ADT(
884 (Name)(Age),
885 (demo::employee) (Name)(Age),
886 (Name const&, Name const&, obj.get_name(), obj.set_name(val))
887 (Age const&, Age const&, obj.get_age(), obj.set_age(val)))
888
889 demo::employee<std::string, int> e;
890 boost::fusion::front(e)="Edward Norton";
891 boost::fusion::back(e)=41;
892 //Prints 'Edward Norton is 41 years old'
893 std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl;
894
895 [heading See also]
896
897 __adt_attribute_proxy__
898
899 [endsect]
900
901 [section:adapt_assoc_adt BOOST_FUSION_ADAPT_ASSOC_ADT]
902
903 BOOST_FUSION_ADAPT_ASSOC_ADT is a macro than can be used to generate all the
904 necessary boilerplate to adapt an arbitrary class type as a model of
905 __random_access_sequence__ and __associative_sequence__.
906
907 [heading Synopsis]
908
909 BOOST_FUSION_ADAPT_ASSOC_ADT(
910 type_name,
911 ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0, key_type0)
912 ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1, key_type1)
913 ...
914 )
915
916 [heading Expression Semantics]
917
918 The above macro generates the necessary code to adapt `type_name`
919 as a model of __random_access_sequence__ and __associative_sequence__.
920 The sequence of
921 [^(attribute_type['N], attribute_const_type['N], get_expr['N], set_expr['N], key_type['N])]
922 5-tuples declares the types, const types, get-expressions, set-expressions and key types
923 of the elements that are part of the adapted fusion sequence.
924 [^get_expr['N]] is the expression that is invoked to get the ['N]th element
925 of an instance of `type_name`. This expression may access a variable named
926 `obj` of type `type_name&` or `type_name const&` which represents the underlying
927 instance of `type_name`.
928 [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types
929 that [^get_expr['N]] denotes to, when omitted the type is deduced from
930 [get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for
931 variadic macros auto can be used to avoid repeating the type.
932 [^set_expr['N]] is the expression that is invoked to set the ['N]th element
933 of an instance of `type_name`. This expression may access variables named
934 `obj` of type `type_name&`, which represent the corresponding instance of
935 `type_name`, and `val` of an arbitrary const-qualified reference template type
936 parameter `Val`, which represents the right operand of the assignment
937 expression.
938
939 The actual return type of fusion's intrinsic sequence access (meta-)functions
940 when in invoked with (an instance of) `type_name` is a proxy type.
941 This type is implicitly convertible to the attribute type via [^get_expr['N]] and
942 forwards assignment to the underlying element via [^set_expr['N]].
943 The value type (that is the type returned by __result_of_value_of__, __result_of_value_of_data__,
944 __result_of_value_at__, __result_of_value_at_c__ and __result_of_value_at_key__) of the ['N]th element
945 is [^attribute_type['N]] with const-qualifier and reference removed.
946
947 The macro should be used at global scope, and `type_name` should be the fully
948 namespace qualified name of the class type to be adapted.
949
950 [heading Header]
951
952 #include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
953 #include <boost/fusion/include/adapt_assoc_adt.hpp>
954
955 [heading Example]
956 namespace demo
957 {
958 struct employee
959 {
960 private:
961 std::string name;
962 int age;
963
964 public:
965 void set_name(std::string const& n)
966 {
967 name=n;
968 }
969
970 void set_age(int a)
971 {
972 age=a;
973 }
974
975 std::string const& get_name()const
976 {
977 return name;
978 }
979
980 int get_age()const
981 {
982 return age;
983 }
984 };
985 }
986
987 namespace keys
988 {
989 struct name;
990 struct age;
991 }
992
993 BOOST_FUSION_ADAPT_ASSOC_ADT(
994 demo::employee,
995 (obj.get_name(), obj.set_name(val), keys::name)
996 (obj.get_age(), obj.set_age(val), keys::age))
997
998 demo::employee e;
999 at_key<keys::name>(e)="Edward Norton";
1000 at_key<keys::age>(e)=41;
1001 //Prints 'Edward Norton is 41 years old'
1002 std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl;
1003
1004 [heading See also]
1005
1006 __adt_attribute_proxy__
1007
1008 [endsect]
1009
1010 [section:adapt_assoc_tpl_adt BOOST_FUSION_ADAPT_ASSOC_TPL_ADT]
1011
1012 BOOST_FUSION_ADAPT_ASSOC_TPL_ADT is a macro than can be used to generate all the
1013 necessary boilerplate to adapt an arbitrary template class type as a model of
1014 __random_access_sequence__ and __associative_sequence__.
1015
1016 [heading Synopsis]
1017
1018 BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
1019 (template_param0)(template_param1)...,
1020 (type_name) (specialization_param0)(specialization_param1)...,
1021 ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0, key_type0)
1022 ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1, key_type1)
1023 ...
1024 )
1025
1026 [heading Expression Semantics]
1027
1028 The above macro generates the necessary code to adapt `type_name`
1029 or an arbitrary specialization of `type_name`
1030 as a model of __random_access_sequence__ and __associative_sequence__.
1031 The sequence `(template_param0)(template_param1)...` declares the names of
1032 the template type parameters used.
1033 The sequence `(specialization_param0)(specialization_param1)...`
1034 declares the template parameters of the actual specialization of `type_name`
1035 that is adapted as a fusion sequence.
1036 The sequence of
1037 [^([attribute_type['N], attribute_const_type['N],] get_expr['N], set_expr['N], key_type['N])]
1038 5-tuples declares the types, const types, get-expressions, set-expressions and key types
1039 of the elements that are part of the adapted fusion sequence.
1040 [^get_expr['N]] is the expression that is invoked to get the ['N]th element
1041 of an instance of `type_name`. This expression may access a variable named
1042 `obj` of type `type_name&` or `type_name const&` which represents the underlying
1043 instance of `type_name`.
1044 [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types
1045 that [^get_expr['N]] denotes to, when omitted the type is deduced from
1046 [get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for
1047 variadic macros auto can be used to avoid repeating the type.
1048 [^set_expr['N]] is the expression that is invoked to set the ['N]th element
1049 of an instance of `type_name`. This expression may access variables named
1050 `obj` of type `type_name&`, which represent the corresponding instance of
1051 `type_name`, and `val` of an arbitrary const-qualified reference template type
1052 parameter `Val`, which represents the right operand of the assignment
1053 expression.
1054
1055 The actual return type of fusion's intrinsic sequence access (meta-)functions
1056 when in invoked with (an instance of) `type_name` is a proxy type.
1057 This type is implicitly convertible to the attribute type via [^get_expr['N]] and
1058 forwards assignment to the underlying element via [^set_expr['N]].
1059 The value type (that is the type returned by __result_of_value_of__, __result_of_value_of_data__,
1060 __result_of_value_at__, __result_of_value_at_c__ and __result_of_value_at_key__) of the ['N]th element
1061 is [^attribute_type['N]] with const-qualifier and reference removed.
1062
1063 The macro should be used at global scope, and `type_name` should be the fully
1064 namespace qualified name of the template class type to be adapted.
1065
1066 [heading Header]
1067
1068 #include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
1069 #include <boost/fusion/include/adapt_assoc_adt.hpp>
1070
1071 [heading Example]
1072 namespace demo
1073 {
1074 template<typename Name, typename Age>
1075 struct employee
1076 {
1077 private:
1078 Name name;
1079 Age age;
1080
1081 public:
1082 void set_name(Name const& n)
1083 {
1084 name=n;
1085 }
1086
1087 void set_age(Age const& a)
1088 {
1089 age=a;
1090 }
1091
1092 Name const& get_name()const
1093 {
1094 return name;
1095 }
1096
1097 Age const& get_age()const
1098 {
1099 return age;
1100 }
1101 };
1102 }
1103
1104 namespace keys
1105 {
1106 struct name;
1107 struct age;
1108 }
1109
1110 BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
1111 (Name)(Age),
1112 (demo::employee) (Name)(Age),
1113 (Name const&, Name const&, obj.get_name(), obj.set_name(val), keys::name)
1114 (Age const&, Age const&, obj.get_age(), obj.set_age(val), keys::age))
1115
1116 demo::employee<std::string, int> e;
1117 at_key<keys::name>(e)="Edward Norton";
1118 at_key<keys::age>(e)=41;
1119 //Prints 'Edward Norton is 41 years old'
1120 std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl;
1121
1122 [heading See also]
1123
1124 __adt_attribute_proxy__
1125
1126 [endsect]
1127
1128 [section:define_struct BOOST_FUSION_DEFINE_STRUCT]
1129
1130 BOOST_FUSION_DEFINE_STRUCT is a macro that can be used to generate all the
1131 necessary boilerplate to define and adapt an arbitrary struct as a model of
1132 __random_access_sequence__.
1133
1134 [heading Synopsis]
1135
1136 BOOST_FUSION_DEFINE_STRUCT(
1137 (namespace0)(namespace1)...,
1138 struct_name,
1139 (member_type0, member_name0)
1140 (member_type1, member_name1)
1141 ...
1142 )
1143
1144 [variablelist Notation
1145 [[`str`] [An instance of `struct_name`]]
1146 [[`e0`...`en`] [Heterogeneous values]]
1147 [[`fs`] [A __forward_sequence__]]
1148 ]
1149
1150 [heading Expression Semantics]
1151
1152 The above macro generates the necessary code that defines and adapts `struct_name`
1153 as a model of __random_access_sequence__.
1154 The sequence `(namespace0)(namespace1)...` declares the namespace
1155 for `struct_name`. It yields to a fully qualified name for `struct_name` of
1156 `namespace0::namespace1::... struct_name`.
1157 If an empty namespace sequence is given (that is a macro that expands to
1158 nothing), the struct is placed in the global namespace.
1159 The sequence of `(member_typeN, member_nameN)`
1160 pairs declares the type and names of each of the struct members that are
1161 part of the sequence.
1162
1163 The macro should be used at global scope.
1164 Semantics of an expression is defined only where it differs from, or is not
1165 defined in __random_access_sequence__.
1166
1167 [table
1168 [[Expression] [Semantics]]
1169 [[`struct_name()`] [Creates an instance of `struct_name` with default constructed elements.]]
1170 [[`struct_name(e0, e1,... en)`] [Creates an instance of `struct_name` with elements `e0`...`en`.]]
1171 [[`struct_name(fs)`] [Copy constructs an instance of `struct_name` from a __forward_sequence__ `fs`.]]
1172 [[`str = fs`] [Assigns from a __forward_sequence__ `fs`.]]
1173 [[`str.member_nameN`] [Access of struct member `member_nameN`]]
1174 ]
1175
1176 [heading Header]
1177
1178 #include <boost/fusion/adapted/struct/define_struct.hpp>
1179 #include <boost/fusion/include/define_struct.hpp>
1180
1181 [heading Example]
1182
1183 // demo::employee is a Fusion sequence
1184 BOOST_FUSION_DEFINE_STRUCT(
1185 (demo), employee,
1186 (std::string, name)
1187 (int, age))
1188
1189 [endsect]
1190
1191 [section:define_tpl_struct BOOST_FUSION_DEFINE_TPL_STRUCT]
1192
1193 [heading Description]
1194
1195 BOOST_FUSION_DEFINE_TPL_STRUCT is a macro that can be used to generate all the
1196 necessary boilerplate to define and adapt an arbitrary template struct as a
1197 model of __random_access_sequence__.
1198
1199 [heading Synopsis]
1200
1201 BOOST_FUSION_DEFINE_TPL_STRUCT(
1202 (template_param0)(template_param1)...,
1203 (namespace0)(namespace1)...,
1204 struct_name,
1205 (member_type0, member_name0)
1206 (member_type1, member_name1)
1207 ...
1208 )
1209
1210 [variablelist Notation
1211 [[`Str`] [An instantiated `struct_name`]]
1212 [[`str`] [An instance of `Str`]]
1213 [[`e0`...`en`] [Heterogeneous values]]
1214 [[`fs`] [A __forward_sequence__]]
1215 ]
1216
1217 [heading Expression Semantics]
1218
1219 The above macro generates the necessary code that defines and adapts `struct_name`
1220 as a model of __random_access_sequence__.
1221 The sequence `(template_param0)(template_param1)...` declares the names of
1222 the template type parameters used.
1223 The sequence `(namespace0)(namespace1)...` declares the namespace
1224 for `struct_name`. It yields to a fully qualified name for `struct_name` of
1225 `namespace0::namespace1::... struct_name`.
1226 If an empty namespace sequence is given (that is a macro that expands to
1227 nothing), the struct is placed in the global namespace.
1228 The sequence of `(member_typeN, member_nameN)`
1229 pairs declares the type and names of each of the struct members that are
1230 part of the sequence.
1231
1232 The macro should be used at global scope.
1233 Semantics of an expression is defined only where it differs from, or is not
1234 defined in __random_access_sequence__.
1235
1236 [table
1237 [[Expression] [Semantics]]
1238 [[`Str()`] [Creates an instance of `Str` with default constructed elements.]]
1239 [[`Str(e0, e1,... en)`] [Creates an instance of `Str` with elements `e0`...`en`.]]
1240 [[`Str(fs)`] [Copy constructs an instance of `Str` from a __forward_sequence__ `fs`.]]
1241 [[`str = fs`] [Assigns from a __forward_sequence__ `fs`.]]
1242 [[`str.member_nameN`] [Access of struct member `member_nameN`]]
1243 ]
1244
1245 [heading Header]
1246
1247 #include <boost/fusion/adapted/struct/define_struct.hpp>
1248 #include <boost/fusion/include/define_struct.hpp>
1249
1250 [heading Example]
1251
1252 // Any instantiated demo::employee is a Fusion sequence
1253 BOOST_FUSION_DEFINE_TPL_STRUCT(
1254 (Name)(Age), (demo), employee,
1255 (Name, name)
1256 (Age, age))
1257
1258 [endsect]
1259
1260 [section:define_struct_inline BOOST_FUSION_DEFINE_STRUCT_INLINE]
1261
1262 [heading Description]
1263
1264 BOOST_FUSION_DEFINE_STRUCT_INLINE is a macro that can be used to generate all
1265 the necessary boilerplate to define and adapt an arbitrary struct as a model of
1266 __random_access_sequence__. Unlike BOOST_FUSION_DEFINE_STRUCT, it can be used
1267 at class or namespace scope.
1268
1269 [heading Synopsis]
1270
1271 BOOST_FUSION_DEFINE_STRUCT_INLINE(
1272 struct_name,
1273 (member_type0, member_name0)
1274 (member_type1, member_name1)
1275 ...
1276 )
1277
1278 [heading Expression Semantics]
1279
1280 The semantics of BOOST_FUSION_DEFINE_STRUCT_INLINE are identical to those of
1281 BOOST_FUSION_DEFINE_STRUCT, with two differences:
1282
1283 # BOOST_FUSION_DEFINE_STRUCT_INLINE can be used at class or namespace scope, and
1284 thus does not take a namespace list parameter.
1285 # The structure generated by BOOST_FUSION_DEFINE_STRUCT_INLINE has a base class,
1286 and is thus not POD in C++03.
1287
1288 [heading Header]
1289
1290 #include <boost/fusion/adapted/struct/define_struct_inline.hpp>
1291 #include <boost/fusion/include/define_struct_inline.hpp>
1292
1293 [heading Example]
1294
1295 // enclosing::employee is a Fusion sequence
1296 class enclosing
1297 {
1298 BOOST_FUSION_DEFINE_STRUCT_INLINE(
1299 employee,
1300 (std::string, name)
1301 (int, age))
1302 };
1303
1304
1305 [endsect]
1306
1307 [section:define_tpl_struct_inline BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE]
1308
1309 [heading Description]
1310
1311 BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE is a macro that can be used to generate
1312 all the necessary boilerplate to define and adapt an arbitrary template struct
1313 as a model of __random_access_sequence__. Unlike BOOST_FUSION_DEFINE_TPL_STRUCT,
1314 it can be used at class or namespace scope.
1315
1316 [heading Synopsis]
1317
1318 BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
1319 (template_param0)(template_param1)...,
1320 struct_name,
1321 (member_type0, member_name0)
1322 (member_type1, member_name1)
1323 ...
1324 )
1325
1326 [heading Expression Semantics]
1327
1328 The semantics of BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE are identical to those of
1329 BOOST_FUSION_DEFINE_TPL_STRUCT, with two differences:
1330
1331 # BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE can be used at class or namespace scope,
1332 and thus does not take a namespace list parameter.
1333 # The structure generated by BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE has a base
1334 class, and is thus not POD in C++03.
1335
1336 [heading Header]
1337
1338 #include <boost/fusion/adapted/struct/define_struct_inline.hpp>
1339 #include <boost/fusion/include/define_struct_inline.hpp>
1340
1341 [heading Example]
1342
1343 // Any instantiated enclosing::employee is a Fusion sequence
1344 class enclosing
1345 {
1346 BOOST_FUSION_DEFINE_TPL_STRUCT(
1347 (Name)(Age), employee,
1348 (Name, name)
1349 (Age, age))
1350 };
1351
1352 [endsect]
1353
1354 [section:define_assoc_struct BOOST_FUSION_DEFINE_ASSOC_STRUCT]
1355
1356 [heading Description]
1357
1358 BOOST_FUSION_DEFINE_ASSOC_STRUCT is a macro that can be used to generate all the
1359 necessary boilerplate to define and adapt an arbitrary struct as a model of
1360 __random_access_sequence__ and __associative_sequence__.
1361
1362 [heading Synopsis]
1363
1364 BOOST_FUSION_DEFINE_ASSOC_STRUCT(
1365 (namespace0)(namespace1)...,
1366 struct_name,
1367 (member_type0, member_name0, key_type0)
1368 (member_type1, member_name1, key_type1)
1369 ...
1370 )
1371
1372 [variablelist Notation
1373 [[`str`] [An instance of `struct_name`]]
1374 [[`e0`...`en`] [Heterogeneous values]]
1375 [[`fs`] [A __forward_sequence__]]
1376 ]
1377
1378 [heading Expression Semantics]
1379
1380 The above macro generates the necessary code that defines and adapts `struct_name`
1381 as a model of __random_access_sequence__ and __associative_sequence__.
1382 The sequence `(namespace0)(namespace1)...` declares the namespace
1383 for `struct_name`. It yields to a fully qualified name for `struct_name` of
1384 `namespace0::namespace1::... struct_name`.
1385 If an empty namespace sequence is given (that is a macro that expands to
1386 nothing), the struct is placed in the global namespace.
1387 The sequence of `(member_typeN, member_nameN, key_typeN)`
1388 triples declares the type, name and key type of each of the struct members
1389 that are part of the sequence.
1390
1391 The macro should be used at global scope.
1392 Semantics of an expression is defined only where it differs from, or is not
1393 defined in __random_access_sequence__ and __associative_sequence__.
1394
1395 [table
1396 [[Expression] [Semantics]]
1397 [[`struct_name()`] [Creates an instance of `struct_name` with default constructed elements.]]
1398 [[`struct_name(e0, e1,... en)`] [Creates an instance of `struct_name` with elements `e0`...`en`.]]
1399 [[`struct_name(fs)`] [Copy constructs an instance of `struct_name` from a __forward_sequence__ `fs`.]]
1400 [[`str = fs`] [Assigns from a __forward_sequence__ `fs`.]]
1401 [[`str.member_nameN`] [Access of struct member `member_nameN`]]
1402 ]
1403
1404 [heading Header]
1405
1406 #include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
1407 #include <boost/fusion/include/define_assoc_struct.hpp>
1408
1409 [heading Example]
1410
1411 namespace keys
1412 {
1413 struct name;
1414 struct age;
1415 }
1416
1417 // demo::employee is a Fusion sequence
1418 BOOST_FUSION_DEFINE_ASSOC_STRUCT(
1419 (demo), employee,
1420 (std::string, name, keys::name)
1421 (int, age, keys::age))
1422
1423 [endsect]
1424
1425 [section:define_assoc_tpl_struct BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT]
1426
1427 [heading Description]
1428
1429 BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT is a macro that can be used to generate all
1430 the necessary boilerplate to define and adapt an arbitrary template struct as a
1431 model of __random_access_sequence__ and __associative_sequence__.
1432
1433 [heading Synopsis]
1434
1435 BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT(
1436 (template_param0)(template_param1)...,
1437 (namespace0)(namespace1)...,
1438 struct_name,
1439 (member_type0, member_name0, key_type0)
1440 (member_type1, member_name1, key_type1)
1441 ...
1442 )
1443
1444 [variablelist Notation
1445 [[`Str`] [An instantiated `struct_name`]]
1446 [[`str`] [An instance of `Str`]]
1447 [[`e0`...`en`] [Heterogeneous values]]
1448 [[`fs`] [A __forward_sequence__]]
1449 ]
1450
1451 [heading Expression Semantics]
1452
1453 The above macro generates the necessary code that defines and adapts
1454 `struct_name` as a model of __random_access_sequence__ and
1455 __associative_sequence__.
1456 The sequence `(template_param0)(template_param1)...` declares the names of
1457 the template type parameters used.
1458 The sequence `(namespace0)(namespace1)...` declares the namespace
1459 for `struct_name`. It yields to a fully qualified name for `struct_name` of
1460 `namespace0::namespace1::... struct_name`.
1461 If an empty namespace sequence is given (that is a macro that expands to
1462 nothing), the struct is placed in the global namespace.
1463 The sequence of `(member_typeN, member_nameN, key_typeN)`
1464 triples declares the type, name and key type of each of the struct members
1465 that are part of the sequence.
1466
1467 The macro should be used at global scope.
1468 Semantics of an expression is defined only where it differs from, or is not
1469 defined in __random_access_sequence__ and __associative_sequence__.
1470
1471 [table
1472 [[Expression] [Semantics]]
1473 [[`Str()`] [Creates an instance of `Str` with default constructed elements.]]
1474 [[`Str(e0, e1,... en)`] [Creates an instance of `Str` with elements `e0`...`en`.]]
1475 [[`Str(fs)`] [Copy constructs an instance of `Str` from a __forward_sequence__ `fs`.]]
1476 [[`str = fs`] [Assigns from a __forward_sequence__ `fs`.]]
1477 [[`str.member_nameN`] [Access of struct member `member_nameN`]]
1478 ]
1479
1480 [heading Header]
1481
1482 #include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
1483 #include <boost/fusion/include/define_assoc_struct.hpp>
1484
1485 [heading Example]
1486
1487 namespace keys
1488 {
1489 struct name;
1490 struct age;
1491 }
1492
1493 // Any instantiated demo::employee is a Fusion sequence
1494 BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT(
1495 (Name)(Age), (demo), employee,
1496 (Name, name, keys::name)
1497 (Age, age, keys::age))
1498
1499 [endsect]
1500
1501 [endsect]