123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503 |
- [/==============================================================================
- Copyright (C) 2001-2011 Joel de Guzman
- Copyright (C) 2006 Dan Marsden
- Copyright (C) 2010 Christopher Schmidt
- Use, modification and distribution is subject to the Boost Software
- License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
- ===============================================================================/]
- [section Adapted]
- Fusion provides a couple of adapters for other sequences such as arrays,
- `std::pair`, __mpl__ sequences, and `boost::array`. These adapters are
- written using Fusion's non-intrusive __extension__ mechanism. If you wish
- to use these sequences with fusion, simply include the necessary files and
- they will be regarded as first-class, fully conforming fusion sequences.
- Fusion also provides various schemes to make it easy for the user to adapt
- various data structures, non-intrusively, as full fledged Fusion sequences.
- [heading Header]
- #include <boost/fusion/adapted.hpp>
- #include <boost/fusion/include/adapted.hpp>
- [section:array Array]
- This module provides adapters for arrays. Including the module
- header makes any array a fully conforming __random_access_sequence__.
- [heading Header]
- #include <boost/fusion/adapted/array.hpp>
- #include <boost/fusion/include/array.hpp>
- [heading Model of]
- * __random_access_sequence__
- [heading Example]
- int arr[3] = {1,2,3};
- std::cout << *__begin__(arr) << std::endl;
- std::cout << *__next__(__begin__(arr)) << std::endl;
- std::cout << *__advance_c__<2>(__begin__(arr)) << std::endl;
- std::cout << *__prior__(__end__(arr)) << std::endl;
- std::cout << __at_c__<2>(arr) << std::endl;
- [endsect]
- [section std::pair]
- This module provides adapters for `std::pair`. Including the module header
- makes `std::pair` a fully conforming __random_access_sequence__.
- [heading Header]
- #include <boost/fusion/adapted/std_pair.hpp>
- #include <boost/fusion/include/std_pair.hpp>
- [heading Model of]
- * __random_access_sequence__
- [heading Example]
- std::pair<int, std::string> p(123, "Hola!!!");
- std::cout << __at_c__<0>(p) << std::endl;
- std::cout << __at_c__<1>(p) << std::endl;
- std::cout << p << std::endl;
- [heading See also]
- __std_pair_doc__, __tr1_tuple_pair__
- [endsect]
- [section std::tuple]
- This module provides adapters for `std::tuple`. Including the module header
- makes `std::tuple` a fully conforming __random_access_sequence__.
- [important To be fully conforming, compiler should support C++11 Variadic Templates.]
- [heading Header]
- #include <boost/fusion/adapted/std_tuple.hpp>
- #include <boost/fusion/include/std_tuple.hpp>
- [heading Model of]
- * __random_access_sequence__
- [heading Example]
- std::tuple<int, std::string, float> p(123, "Hola!!!", 456.f);
- std::cout << __at_c__<0>(p) << std::endl;
- std::cout << __at_c__<1>(p) << std::endl;
- std::cout << p << std::endl;
- [heading See also]
- __std_tuple_doc__
- [endsect]
- [section mpl sequence]
- This module provides adapters for __mpl__ sequences. Including the module
- header makes all __mpl__ sequences fully conforming fusion sequences.
- [heading Header]
- #include <boost/fusion/adapted/mpl.hpp>
- #include <boost/fusion/include/mpl.hpp>
- [heading Model of]
- * __forward_sequence__ (If the __mpl__ sequence is a forward sequence.)
- * __bidirectional_sequence__ (If the __mpl__ sequence is a bidirectional sequence.)
- * __random_access_sequence__ (If the __mpl__ sequence is a random access sequence.)
- [heading Example]
- mpl::vector_c<int, 123, 456> vec_c;
- fusion::vector2<int, long> v(vec_c);
- std::cout << __at_c__<0>(v) << std::endl;
- std::cout << __at_c__<1>(v) << std::endl;
- v = mpl::vector_c<int, 456, 789>();
- std::cout << __at_c__<0>(v) << std::endl;
- std::cout << __at_c__<1>(v) << std::endl;
- [heading Bi-directional adaptation]
- Fusion sequences may also be adapted as fully conforming __mpl__ sequences (see
- __intrinsics__). That way, we can have 2-way adaptation to and from __mpl__ and
- Fusion. To make Fusion sequences fully conforming __mpl__ sequences, include:
- #include <boost/fusion/mpl.hpp>
- If you want bi-directional adaptation to and from __mpl__ and Fusion, simply
- include:
- #include <boost/fusion/include/mpl.hpp>
- The header includes all the necessary headers.
- [heading See also]
- __mpl__
- [endsect]
- [section boost::array]
- This module provides adapters for `boost::array`. Including the module
- header makes `boost::array` a fully conforming __random_access_sequence__.
- [heading Header]
- #include <boost/fusion/adapted/boost_array.hpp>
- #include <boost/fusion/include/boost_array.hpp>
- [heading Model of]
- * __random_access_sequence__
- [heading Example]
- boost::array<int,3> arr = {{1,2,3}};
- std::cout << *__begin__(arr) << std::endl;
- std::cout << *__next__(__begin__(arr)) << std::endl;
- std::cout << *__advance_c__<2>(__begin__(arr)) << std::endl;
- std::cout << *__prior__(__end__(arr)) << std::endl;
- std::cout << __at_c__<2>(arr) << std::endl;
- [heading See also]
- __boost_array_library__
- [endsect]
- [section boost::tuple]
- This module provides adapters for `boost::tuple`. Including the module
- header makes `boost::tuple` a fully conforming __forward_sequence__.
- [heading Header]
- #include <boost/fusion/adapted/boost_tuple.hpp>
- #include <boost/fusion/include/boost_tuple.hpp>
- [heading Model of]
- * __forward_sequence__
- [heading Example]
- boost::tuple<int,std::string> example_tuple(101, "hello");
- std::cout << *__begin__(example_tuple) << '\n';
- std::cout << *__next__(__begin__(example_tuple)) << '\n';
- [heading See also]
- __boost_tuple_library__
- [endsect]
- [section:adapt_struct BOOST_FUSION_ADAPT_STRUCT]
- [heading Description]
- BOOST_FUSION_ADAPT_STRUCT is a macro that can be used to generate all the
- necessary boilerplate to make an arbitrary struct a model of
- __random_access_sequence__.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_STRUCT(
- struct_name,
- member_name0,
- member_name1,
- member_name2,
- ...
- )
- // Without BOOST_PP_VARIADICS support :
- BOOST_FUSION_ADAPT_STRUCT(
- struct_name,
- (member_type0, member_name0)
- (member_type1, member_name1)
- (auto, member_name2)
- ...
- )
- [heading Semantics]
- The above macro generates the necessary code to adapt `struct_name`
- as a model of __random_access_sequence__.
- The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)`
- pairs declares the type and names of each of the struct members that are part of
- the sequence.
- When member_typeN is omitted or set to auto, the type is
- infered with Boost.TypeOf.
- The macro should be used at global scope, and `struct_name` should be the fully
- namespace qualified name of the struct to be adapted.
- [heading Header]
- #include <boost/fusion/adapted/struct/adapt_struct.hpp>
- #include <boost/fusion/include/adapt_struct.hpp>
- [heading Example: BOOST_FUSION_ADAPT_STRUCT ]
- namespace demo
- {
- struct employee
- {
- std::string name;
- int age;
- };
- }
- // demo::employee is now a Fusion sequence
- BOOST_FUSION_ADAPT_STRUCT(
- demo::employee,
- name,
- age)
- // Without BOOST_PP_VARIADICS support :
- BOOST_FUSION_ADAPT_STRUCT(
- demo::employee,
- (auto, name)
- (auto, age)
- )
- [endsect]
- [section:adapt_tpl_struct BOOST_FUSION_ADAPT_TPL_STRUCT]
- [heading Description]
- BOOST_FUSION_ADAPT_TPL_STRUCT is a macro that can be used to generate all the
- necessary boilerplate to make an arbitrary template struct a model of
- __random_access_sequence__.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_TPL_STRUCT(
- (template_param0)(template_param1)...,
- (struct_name) (specialization_param0)(specialization_param1)...,
- member_name0,
- member_name1
- ...
- )
- // Without BOOST_PP_VARIADICS support :
- BOOST_FUSION_ADAPT_TPL_STRUCT(
- (template_param0)(template_param1)...,
- (struct_name) (specialization_param0)(specialization_param1)...,
- (member_type0, member_name0)
- (member_type1, member_name1)
- (auto, member_name2),
- ...
- )
- [heading Semantics]
- The above macro generates the necessary code to adapt `struct_name` or an
- arbitrary specialization of `struct_name` as a model of
- __random_access_sequence__.
- The sequence `(template_param0)(template_param1)...` declares the names of
- the template type parameters used.
- The sequence `(specialization_param0)(specialization_param1)...`
- declares the template parameters of the actual specialization of `struct_name`
- that is adapted as a fusion sequence.
- The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)`
- pairs declares the type and names of each of the struct members that are part of
- the sequence.
- When member_typeN is omitted or set to auto, the type is
- infered with Boost.TypeOf.
- The macro should be used at global scope, and `struct_name` should be the fully
- namespace qualified name of the struct to be adapted.
- [heading Header]
- #include <boost/fusion/adapted/struct/adapt_struct.hpp>
- #include <boost/fusion/include/adapt_struct.hpp>
- [heading Example]
- namespace demo
- {
- template<typename Name, typename Age>
- struct employee
- {
- Name name;
- Age age;
- int employment_timestamp;
- };
- }
- // Any instantiated demo::employee is now a Fusion sequence
- BOOST_FUSION_ADAPT_TPL_STRUCT(
- (Name)(Age),
- (demo::employee) (Name)(Age),
- (Name, name)
- (Age, age)
- (auto, employment_timestamp))
- // Or by infering type completely
- BOOST_FUSION_ADAPT_TPL_STRUCT(
- (Name)(Age),
- (demo::employee) (Name)(Age),
- name,
- age,
- employment_timestamp)
- [endsect]
- [section:adapt_struct_named BOOST_FUSION_ADAPT_STRUCT_NAMED]
- [heading Description]
- BOOST_FUSION_ADAPT_STRUCT_NAMED and BOOST_FUSION_ADAPT_STRUCT_NAMED_NS are
- macros that can be used to generate all the necessary boilerplate to make an
- arbitrary struct a model of __random_access_sequence__. The given struct is
- adapted using the given name.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_STRUCT_NAMED(
- struct_name, adapted_name,
- member_name0,
- member_name1,
- member_name2,
- ...
- )
- BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(
- struct_name,
- (namespace0)(namespace1)...,
- adapted_name,
- member_name0,
- member_name1,
- member_name2,
- ...
- )
- // Without BOOST_PP_VARIADICS support :
- BOOST_FUSION_ADAPT_STRUCT_NAMED(
- struct_name, adapted_name,
- (member_type0, member_name0)
- (member_type1, member_name1)
- (auto, member_name2),
- ...
- )
- BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(
- struct_name,
- (namespace0)(namespace1)...,
- adapted_name,
- (member_type0, member_name0)
- (member_type1, member_name1)
- (auto, member_name2),
- ...
- )
- [heading Semantics]
- The above macros generate the necessary code to adapt `struct_name`
- as a model of __random_access_sequence__ while using `adapted_name` as the
- name of the adapted struct.
- The sequence `(namespace0)(namespace1)...` declares the namespace
- for `adapted_name`. It yields to a fully qualified name for `adapted_name` of
- `namespace0::namespace1::... adapted_name`.
- If an empty namespace sequence is given (that is a macro that expands to
- nothing), the adapted view is placed in the global namespace.
- If no namespace sequence is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_NAMED`), the
- adapted view is placed in the namespace `boost::fusion::adapted`.
- The sequence of `member_nameN,` arguments or `(member_typeN, member_nameN)`
- pairs declares the type and names of each of the struct members that are part of
- the sequence.
- When member_typeN is omitted or set to auto, the type is
- infered with Boost.TypeOf.
- The macros should be used at global scope, and `struct_name` should be the fully
- namespace qualified name of the struct to be converted.
- [heading Header]
- #include <boost/fusion/adapted/struct/adapt_struct_named.hpp>
- #include <boost/fusion/include/adapt_struct_named.hpp>
- [heading Example]
- namespace demo
- {
- struct employee
- {
- std::string name;
- int age;
- };
- }
- // boost::fusion::adapted::adapted_employee is now a Fusion sequence
- // referring to demo::employee
- BOOST_FUSION_ADAPT_STRUCT_NAMED(
- demo::employee, adapted_employee,
- name,
- age)
- // Without BOOST_PP_VARIADICS support :
- BOOST_FUSION_ADAPT_STRUCT_NAMED(
- demo::employee, adapted_employee,
- (auto, name),
- (auto, age))
- [endsect]
- [section:adapt_assoc BOOST_FUSION_ADAPT_ASSOC_STRUCT]
- [heading Description]
- BOOST_FUSION_ADAPT_ASSOC_STRUCT is a macro that can be used to generate all the
- necessary boilerplate to make an arbitrary struct a model of
- __random_access_sequence__ and __associative_sequence__.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_ASSOC_STRUCT(
- struct_name,
- ([member_type0,] member_name0, key_type0)
- ([member_type1,] member_name1, key_type1)
- ...
- )
- [heading Semantics]
- The above macro generates the necessary code to adapt `struct_name`
- as a model of __random_access_sequence__ and __associative_sequence__.
- The sequence of `([member_typeN,] member_nameN, key_typeN)` tuples
- declares the type, name and key type of each of the struct members
- that are part of the sequence.
- When member_typeN is omitted or set to auto, the type is
- infered with Boost.TypeOf.
- The macro should be used at global scope, and `struct_name` should be the fully
- namespace qualified name of the struct to be adapted.
- [heading Header]
- #include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
- #include <boost/fusion/include/adapt_assoc_struct.hpp>
- [heading Example]
- namespace demo
- {
- struct employee
- {
- std::string name;
- int age;
- };
- }
- namespace keys
- {
- struct name;
- struct age;
- }
- // demo::employee is now a Fusion sequence.
- // It is also an associative sequence with
- // keys keys::name and keys::age present.
- BOOST_FUSION_ADAPT_ASSOC_STRUCT(
- demo::employee,
- (name, keys::name)
- (age, keys::age))
- // Without BOOST_PP_VARIADICS support :
- BOOST_FUSION_ADAPT_ASSOC_STRUCT(
- demo::employee,
- (auto, name, keys::name),
- (auto, age, keys::name))
- [endsect]
- [section:adapt_assoc_tpl_struct BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT]
- [heading Description]
- BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT is a macro that can be used to generate all the
- necessary boilerplate to make an arbitrary template struct a model of
- __random_access_sequence__ and __associative_sequence__.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
- (template_param0)(template_param1)...,
- (struct_name) (specialization_param0)(specialization_param1)...,
- ([member_type0,] member_name0, key_type0)
- ([member_type1,] member_name1, key_type1)
- ...
- )
- [heading Semantics]
- The above macro generates the necessary code to adapt `struct_name` or an
- arbitrary specialization of `struct_name` as a model of
- __random_access_sequence__ and __associative_sequence__.
- The sequence `(template_param0)(template_param1)...` declares the names of
- the template type parameters used.
- The sequence `(specialization_param0)(specialization_param1)...`
- declares the template parameters of the actual specialization of `struct_name`
- that is adapted as a fusion sequence.
- The sequence of `([member_typeN,] member_nameN, key_typeN)`
- tuples declares the type, name and key type of each of the struct members
- that are part of the sequence.
- When member_typeN is omitted or set to auto, the type is
- infered with Boost.TypeOf.
- The macro should be used at global scope, and `struct_name` should be the fully
- namespace qualified name of the struct to be adapted.
- [heading Header]
- #include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
- #include <boost/fusion/include/adapt_assoc_struct.hpp>
- [heading Example]
- namespace demo
- {
- template<typename Name, typename Age>
- struct employee
- {
- Name name;
- Age age;
- };
- }
- namespace keys
- {
- struct name;
- struct age;
- }
- // Any instantiated demo::employee is now a Fusion sequence.
- // It is also an associative sequence with
- // keys keys::name and keys::age present.
- BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
- (Name)(Age),
- (demo::employee) (Name)(Age),
- (name, keys::name)
- (age, keys::age))
- // Without BOOST_PP_VARIADICS support :
- BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
- (Name)(Age),
- (demo::employee) (Name)(Age),
- (Name, name, keys::name)
- (Age, age, keys::age))
- [endsect]
- [section:adapt_assoc_struct_named BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED]
- [heading Description]
- BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED and BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS are
- macros that can be used to generate all the necessary boilerplate to make an
- arbitrary struct a model of __random_access_sequence__ and
- __associative_sequence__. The given struct is adapted using the given name.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
- struct_name, adapted_name,
- ([member_type0,] member_name0, key_type0)
- ([member_type1,] member_name1, key_type1)
- ...
- )
- BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS(
- struct_name,
- (namespace0)(namespace1)...,
- adapted_name,
- ([member_type0,] member_name0, key_type0)
- ([member_type1,] member_name1, key_type1)
- ...
- )
- [heading Semantics]
- The above macros generate the necessary code to adapt `struct_name`
- as a model of __random_access_sequence__ and __associative_sequence__ while
- using `adapted_name` as the name of the adapted struct.
- The sequence `(namespace0)(namespace1)...` declares the namespace
- for `adapted_name`. It yields to a fully qualified name for `adapted_name` of
- `namespace0::namespace1::... adapted_name`.
- If an empty namespace sequence is given (that is a macro that expands to
- nothing), the adapted view is placed in the global namespace.
- If no namespace sequence is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_ASSOC_NAMED`), the
- adapted view is placed in the namespace `boost::fusion::adapted`.
- The sequence of `(member_typeN, member_nameN, key_typeN)`
- triples declares the type, name and key type of each of the struct members
- that are part of the sequence.
- When member_typeN is omitted or set to auto, the type is
- infered with Boost.TypeOf.
- The macros should be used at global scope, and `struct_name` should be the fully
- namespace qualified name of the struct to be converted.
- [heading Header]
- #include <boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp>
- #include <boost/fusion/include/adapt_assoc_struct_named.hpp>
- [heading Example]
- namespace demo
- {
- struct employee
- {
- std::string name;
- int age;
- };
- }
- namespace keys
- {
- struct name;
- struct age;
- }
- // boost::fusion::adapted::adapted_employee is now a Fusion sequence
- // referring to demo::employee
- BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
- demo::employee, adapted_employee,
- (name, keys::name)
- (age, keys::age))
- // Without BOOST_PP_VARIADICS support :
- BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
- demo::employee, adapted_employee,
- (auto, name, keys::name)
- (auto, age, keys::age))
- [endsect]
- [section:adapt_adt BOOST_FUSION_ADAPT_ADT]
- BOOST_FUSION_ADAPT_ADT is a macro than can be used to generate all the
- necessary boilerplate to adapt an arbitrary class type as a model of
- __random_access_sequence__.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_ADT(
- type_name,
- ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0)
- ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1)
- ...
- )
- [heading Expression Semantics]
- The above macro generates the necessary code to adapt `type_name`
- as a model of __random_access_sequence__.
- The sequence of
- [^([attribute_type['N], attribute_const_type['N],] get_expr['N], set_expr['N])]
- quadruples declares the types, const types, get-expressions and set-expressions
- of the elements that are part of the adapted fusion sequence.
- [^get_expr['N]] is the expression that is invoked to get the ['N]th element
- of an instance of `type_name`. This expression may access a variable named
- `obj` of type `type_name&` or `type_name const&` which represents the underlying
- instance of `type_name`.
- [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types
- that [^get_expr['N]] denotes to, when omitted the type is deduced from
- [get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for
- variadic macros auto can be used to avoid repeating the type.
- [^set_expr['N]] is the expression that is invoked to set the ['N]th element
- of an instance of `type_name`. This expression may access variables named
- `obj` of type `type_name&`, which represent the corresponding instance of
- `type_name`, and `val` of an arbitrary const-qualified reference template type
- parameter `Val`, which represents the right operand of the assignment
- expression.
- The actual return type of fusion's intrinsic sequence access (meta-)functions
- when in invoked with (an instance of) `type_name` is a proxy type.
- This type is implicitly convertible to the attribute type via [^get_expr['N]] and
- forwards assignment to the underlying element via [^set_expr['N]].
- The value type (that is the type returned by __result_of_value_of__,
- __result_of_value_at__ and __result_of_value_at_c__) of the ['N]th element
- is [^attribute_type['N]] with const-qualifier and reference removed.
- The macro should be used at global scope, and `type_name` should be the fully
- namespace qualified name of the class type to be adapted.
- [heading Header]
- #include <boost/fusion/adapted/adt/adapt_adt.hpp>
- #include <boost/fusion/include/adapt_adt.hpp>
- [heading Example]
- namespace demo
- {
- struct employee
- {
- private:
- std::string name;
- int age;
- public:
- void set_name(std::string const& n)
- {
- name=n;
- }
- void set_age(int a)
- {
- age=a;
- }
- std::string const& get_name()const
- {
- return name;
- }
- int get_age()const
- {
- return age;
- }
- };
- }
- BOOST_FUSION_ADAPT_ADT(
- demo::employee,
- (obj.get_name(), obj.set_name(val))
- (obj.get_age(), obj.set_age(val)))
- demo::employee e;
- front(e)="Edward Norton";
- back(e)=41;
- //Prints 'Edward Norton is 41 years old'
- std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl;
- [heading See also]
- __adt_attribute_proxy__
- [endsect]
- [section:adapt_tpl_adt BOOST_FUSION_ADAPT_TPL_ADT]
- BOOST_FUSION_ADAPT_TPL_ADT is a macro than can be used to generate all the
- necessary boilerplate to adapt an arbitrary template class type as a model of
- __random_access_sequence__.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_TPL_ADT(
- (template_param0)(template_param1)...,
- (type_name) (specialization_param0)(specialization_param1)...,
- ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0)
- ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1)
- ...
- )
- [heading Expression Semantics]
- The above macro generates the necessary code to adapt `type_name`
- or an arbitrary specialization of `type_name`
- as a model of __random_access_sequence__.
- The sequence `(template_param0)(template_param1)...` declares the names of
- the template type parameters used.
- The sequence `(specialization_param0)(specialization_param1)...`
- declares the template parameters of the actual specialization of `type_name`
- that is adapted as a fusion sequence.
- The sequence of
- [^(attribute_type['N], attribute_const_type['N], get_expr['N], set_expr['N])]
- quadruples declares the types, const types, get-expressions and set-expressions
- of the elements that are part of the adapted fusion sequence.
- [^get_expr['N]] is the expression that is invoked to get the ['N]th element
- of an instance of `type_name`. This expression may access a variable named
- `obj` of type `type_name&` or `type_name const&` which represents the underlying
- instance of `type_name`.
- [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types
- that [^get_expr['N]] denotes to, when omitted the type is deduced from
- [get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for
- variadic macros auto can be used to avoid repeating the type.
- [^set_expr['N]] is the expression that is invoked to set the ['N]th element
- of an instance of `type_name`. This expression may access variables named
- `obj` of type `type_name&`, which represent the corresponding instance of
- `type_name`, and `val` of an arbitrary const-qualified reference template type
- parameter `Val`, which represents the right operand of the assignment
- expression.
- The actual return type of fusion's intrinsic sequence access (meta-)functions
- when in invoked with (an instance of) `type_name` is a proxy type.
- This type is implicitly convertible to the attribute type via [^get_expr['N]] and
- forwards assignment to the underlying element via [^set_expr['N]].
- The value type (that is the type returned by __result_of_value_of__,
- __result_of_value_at__ and __result_of_value_at_c__) of the ['N]th element
- is [^attribute_type['N]] with const-qualifier and reference removed.
- The macro should be used at global scope, and `type_name` should be the fully
- namespace qualified name of the template class type to be adapted.
- [heading Header]
- #include <boost/fusion/adapted/adt/adapt_adt.hpp>
- #include <boost/fusion/include/adapt_adt.hpp>
- [heading Example]
- namespace demo
- {
- template<typename Name, typename Age>
- struct employee
- {
- private:
- Name name;
- Age age;
- public:
- void set_name(Name const& n)
- {
- name=n;
- }
- void set_age(Age const& a)
- {
- age=a;
- }
- Name const& get_name()const
- {
- return name;
- }
- Age const& get_age()const
- {
- return age;
- }
- };
- }
- BOOST_FUSION_ADAPT_TPL_ADT(
- (Name)(Age),
- (demo::employee) (Name)(Age),
- (Name const&, Name const&, obj.get_name(), obj.set_name(val))
- (Age const&, Age const&, obj.get_age(), obj.set_age(val)))
- demo::employee<std::string, int> e;
- boost::fusion::front(e)="Edward Norton";
- boost::fusion::back(e)=41;
- //Prints 'Edward Norton is 41 years old'
- std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl;
- [heading See also]
- __adt_attribute_proxy__
- [endsect]
- [section:adapt_assoc_adt BOOST_FUSION_ADAPT_ASSOC_ADT]
- BOOST_FUSION_ADAPT_ASSOC_ADT is a macro than can be used to generate all the
- necessary boilerplate to adapt an arbitrary class type as a model of
- __random_access_sequence__ and __associative_sequence__.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_ASSOC_ADT(
- type_name,
- ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0, key_type0)
- ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1, key_type1)
- ...
- )
- [heading Expression Semantics]
- The above macro generates the necessary code to adapt `type_name`
- as a model of __random_access_sequence__ and __associative_sequence__.
- The sequence of
- [^(attribute_type['N], attribute_const_type['N], get_expr['N], set_expr['N], key_type['N])]
- 5-tuples declares the types, const types, get-expressions, set-expressions and key types
- of the elements that are part of the adapted fusion sequence.
- [^get_expr['N]] is the expression that is invoked to get the ['N]th element
- of an instance of `type_name`. This expression may access a variable named
- `obj` of type `type_name&` or `type_name const&` which represents the underlying
- instance of `type_name`.
- [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types
- that [^get_expr['N]] denotes to, when omitted the type is deduced from
- [get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for
- variadic macros auto can be used to avoid repeating the type.
- [^set_expr['N]] is the expression that is invoked to set the ['N]th element
- of an instance of `type_name`. This expression may access variables named
- `obj` of type `type_name&`, which represent the corresponding instance of
- `type_name`, and `val` of an arbitrary const-qualified reference template type
- parameter `Val`, which represents the right operand of the assignment
- expression.
- The actual return type of fusion's intrinsic sequence access (meta-)functions
- when in invoked with (an instance of) `type_name` is a proxy type.
- This type is implicitly convertible to the attribute type via [^get_expr['N]] and
- forwards assignment to the underlying element via [^set_expr['N]].
- The value type (that is the type returned by __result_of_value_of__, __result_of_value_of_data__,
- __result_of_value_at__, __result_of_value_at_c__ and __result_of_value_at_key__) of the ['N]th element
- is [^attribute_type['N]] with const-qualifier and reference removed.
- The macro should be used at global scope, and `type_name` should be the fully
- namespace qualified name of the class type to be adapted.
- [heading Header]
- #include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
- #include <boost/fusion/include/adapt_assoc_adt.hpp>
- [heading Example]
- namespace demo
- {
- struct employee
- {
- private:
- std::string name;
- int age;
- public:
- void set_name(std::string const& n)
- {
- name=n;
- }
- void set_age(int a)
- {
- age=a;
- }
- std::string const& get_name()const
- {
- return name;
- }
- int get_age()const
- {
- return age;
- }
- };
- }
- namespace keys
- {
- struct name;
- struct age;
- }
- BOOST_FUSION_ADAPT_ASSOC_ADT(
- demo::employee,
- (obj.get_name(), obj.set_name(val), keys::name)
- (obj.get_age(), obj.set_age(val), keys::age))
- demo::employee e;
- at_key<keys::name>(e)="Edward Norton";
- at_key<keys::age>(e)=41;
- //Prints 'Edward Norton is 41 years old'
- std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl;
- [heading See also]
- __adt_attribute_proxy__
- [endsect]
- [section:adapt_assoc_tpl_adt BOOST_FUSION_ADAPT_ASSOC_TPL_ADT]
- BOOST_FUSION_ADAPT_ASSOC_TPL_ADT is a macro than can be used to generate all the
- necessary boilerplate to adapt an arbitrary template class type as a model of
- __random_access_sequence__ and __associative_sequence__.
- [heading Synopsis]
- BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
- (template_param0)(template_param1)...,
- (type_name) (specialization_param0)(specialization_param1)...,
- ([attribute_type0, attribute_const_type0,] get_expr0, set_expr0, key_type0)
- ([attribute_type1, attribute_const_type1,] get_expr1, set_expr1, key_type1)
- ...
- )
- [heading Expression Semantics]
- The above macro generates the necessary code to adapt `type_name`
- or an arbitrary specialization of `type_name`
- as a model of __random_access_sequence__ and __associative_sequence__.
- The sequence `(template_param0)(template_param1)...` declares the names of
- the template type parameters used.
- The sequence `(specialization_param0)(specialization_param1)...`
- declares the template parameters of the actual specialization of `type_name`
- that is adapted as a fusion sequence.
- The sequence of
- [^([attribute_type['N], attribute_const_type['N],] get_expr['N], set_expr['N], key_type['N])]
- 5-tuples declares the types, const types, get-expressions, set-expressions and key types
- of the elements that are part of the adapted fusion sequence.
- [^get_expr['N]] is the expression that is invoked to get the ['N]th element
- of an instance of `type_name`. This expression may access a variable named
- `obj` of type `type_name&` or `type_name const&` which represents the underlying
- instance of `type_name`.
- [^attribute_type['N]] and [^attribute_const_type['N]] may specify the types
- that [^get_expr['N]] denotes to, when omitted the type is deduced from
- [get_expr['N]] return type via BOOST_TYPEOF. On compiler missing support for
- variadic macros auto can be used to avoid repeating the type.
- [^set_expr['N]] is the expression that is invoked to set the ['N]th element
- of an instance of `type_name`. This expression may access variables named
- `obj` of type `type_name&`, which represent the corresponding instance of
- `type_name`, and `val` of an arbitrary const-qualified reference template type
- parameter `Val`, which represents the right operand of the assignment
- expression.
- The actual return type of fusion's intrinsic sequence access (meta-)functions
- when in invoked with (an instance of) `type_name` is a proxy type.
- This type is implicitly convertible to the attribute type via [^get_expr['N]] and
- forwards assignment to the underlying element via [^set_expr['N]].
- The value type (that is the type returned by __result_of_value_of__, __result_of_value_of_data__,
- __result_of_value_at__, __result_of_value_at_c__ and __result_of_value_at_key__) of the ['N]th element
- is [^attribute_type['N]] with const-qualifier and reference removed.
- The macro should be used at global scope, and `type_name` should be the fully
- namespace qualified name of the template class type to be adapted.
- [heading Header]
- #include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
- #include <boost/fusion/include/adapt_assoc_adt.hpp>
- [heading Example]
- namespace demo
- {
- template<typename Name, typename Age>
- struct employee
- {
- private:
- Name name;
- Age age;
- public:
- void set_name(Name const& n)
- {
- name=n;
- }
- void set_age(Age const& a)
- {
- age=a;
- }
- Name const& get_name()const
- {
- return name;
- }
- Age const& get_age()const
- {
- return age;
- }
- };
- }
- namespace keys
- {
- struct name;
- struct age;
- }
- BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
- (Name)(Age),
- (demo::employee) (Name)(Age),
- (Name const&, Name const&, obj.get_name(), obj.set_name(val), keys::name)
- (Age const&, Age const&, obj.get_age(), obj.set_age(val), keys::age))
- demo::employee<std::string, int> e;
- at_key<keys::name>(e)="Edward Norton";
- at_key<keys::age>(e)=41;
- //Prints 'Edward Norton is 41 years old'
- std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl;
- [heading See also]
- __adt_attribute_proxy__
- [endsect]
- [section:define_struct BOOST_FUSION_DEFINE_STRUCT]
- BOOST_FUSION_DEFINE_STRUCT is a macro that can be used to generate all the
- necessary boilerplate to define and adapt an arbitrary struct as a model of
- __random_access_sequence__.
- [heading Synopsis]
- BOOST_FUSION_DEFINE_STRUCT(
- (namespace0)(namespace1)...,
- struct_name,
- (member_type0, member_name0)
- (member_type1, member_name1)
- ...
- )
- [variablelist Notation
- [[`str`] [An instance of `struct_name`]]
- [[`e0`...`en`] [Heterogeneous values]]
- [[`fs`] [A __forward_sequence__]]
- ]
- [heading Expression Semantics]
- The above macro generates the necessary code that defines and adapts `struct_name`
- as a model of __random_access_sequence__.
- The sequence `(namespace0)(namespace1)...` declares the namespace
- for `struct_name`. It yields to a fully qualified name for `struct_name` of
- `namespace0::namespace1::... struct_name`.
- If an empty namespace sequence is given (that is a macro that expands to
- nothing), the struct is placed in the global namespace.
- The sequence of `(member_typeN, member_nameN)`
- pairs declares the type and names of each of the struct members that are
- part of the sequence.
- The macro should be used at global scope.
- Semantics of an expression is defined only where it differs from, or is not
- defined in __random_access_sequence__.
- [table
- [[Expression] [Semantics]]
- [[`struct_name()`] [Creates an instance of `struct_name` with default constructed elements.]]
- [[`struct_name(e0, e1,... en)`] [Creates an instance of `struct_name` with elements `e0`...`en`.]]
- [[`struct_name(fs)`] [Copy constructs an instance of `struct_name` from a __forward_sequence__ `fs`.]]
- [[`str = fs`] [Assigns from a __forward_sequence__ `fs`.]]
- [[`str.member_nameN`] [Access of struct member `member_nameN`]]
- ]
- [heading Header]
- #include <boost/fusion/adapted/struct/define_struct.hpp>
- #include <boost/fusion/include/define_struct.hpp>
- [heading Example]
- // demo::employee is a Fusion sequence
- BOOST_FUSION_DEFINE_STRUCT(
- (demo), employee,
- (std::string, name)
- (int, age))
- [endsect]
- [section:define_tpl_struct BOOST_FUSION_DEFINE_TPL_STRUCT]
- [heading Description]
- BOOST_FUSION_DEFINE_TPL_STRUCT is a macro that can be used to generate all the
- necessary boilerplate to define and adapt an arbitrary template struct as a
- model of __random_access_sequence__.
- [heading Synopsis]
- BOOST_FUSION_DEFINE_TPL_STRUCT(
- (template_param0)(template_param1)...,
- (namespace0)(namespace1)...,
- struct_name,
- (member_type0, member_name0)
- (member_type1, member_name1)
- ...
- )
- [variablelist Notation
- [[`Str`] [An instantiated `struct_name`]]
- [[`str`] [An instance of `Str`]]
- [[`e0`...`en`] [Heterogeneous values]]
- [[`fs`] [A __forward_sequence__]]
- ]
- [heading Expression Semantics]
- The above macro generates the necessary code that defines and adapts `struct_name`
- as a model of __random_access_sequence__.
- The sequence `(template_param0)(template_param1)...` declares the names of
- the template type parameters used.
- The sequence `(namespace0)(namespace1)...` declares the namespace
- for `struct_name`. It yields to a fully qualified name for `struct_name` of
- `namespace0::namespace1::... struct_name`.
- If an empty namespace sequence is given (that is a macro that expands to
- nothing), the struct is placed in the global namespace.
- The sequence of `(member_typeN, member_nameN)`
- pairs declares the type and names of each of the struct members that are
- part of the sequence.
- The macro should be used at global scope.
- Semantics of an expression is defined only where it differs from, or is not
- defined in __random_access_sequence__.
- [table
- [[Expression] [Semantics]]
- [[`Str()`] [Creates an instance of `Str` with default constructed elements.]]
- [[`Str(e0, e1,... en)`] [Creates an instance of `Str` with elements `e0`...`en`.]]
- [[`Str(fs)`] [Copy constructs an instance of `Str` from a __forward_sequence__ `fs`.]]
- [[`str = fs`] [Assigns from a __forward_sequence__ `fs`.]]
- [[`str.member_nameN`] [Access of struct member `member_nameN`]]
- ]
- [heading Header]
- #include <boost/fusion/adapted/struct/define_struct.hpp>
- #include <boost/fusion/include/define_struct.hpp>
- [heading Example]
- // Any instantiated demo::employee is a Fusion sequence
- BOOST_FUSION_DEFINE_TPL_STRUCT(
- (Name)(Age), (demo), employee,
- (Name, name)
- (Age, age))
- [endsect]
- [section:define_struct_inline BOOST_FUSION_DEFINE_STRUCT_INLINE]
- [heading Description]
- BOOST_FUSION_DEFINE_STRUCT_INLINE is a macro that can be used to generate all
- the necessary boilerplate to define and adapt an arbitrary struct as a model of
- __random_access_sequence__. Unlike BOOST_FUSION_DEFINE_STRUCT, it can be used
- at class or namespace scope.
- [heading Synopsis]
- BOOST_FUSION_DEFINE_STRUCT_INLINE(
- struct_name,
- (member_type0, member_name0)
- (member_type1, member_name1)
- ...
- )
- [heading Expression Semantics]
- The semantics of BOOST_FUSION_DEFINE_STRUCT_INLINE are identical to those of
- BOOST_FUSION_DEFINE_STRUCT, with two differences:
- # BOOST_FUSION_DEFINE_STRUCT_INLINE can be used at class or namespace scope, and
- thus does not take a namespace list parameter.
- # The structure generated by BOOST_FUSION_DEFINE_STRUCT_INLINE has a base class,
- and is thus not POD in C++03.
- [heading Header]
- #include <boost/fusion/adapted/struct/define_struct_inline.hpp>
- #include <boost/fusion/include/define_struct_inline.hpp>
- [heading Example]
- // enclosing::employee is a Fusion sequence
- class enclosing
- {
- BOOST_FUSION_DEFINE_STRUCT_INLINE(
- employee,
- (std::string, name)
- (int, age))
- };
- [endsect]
- [section:define_tpl_struct_inline BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE]
- [heading Description]
- BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE is a macro that can be used to generate
- all the necessary boilerplate to define and adapt an arbitrary template struct
- as a model of __random_access_sequence__. Unlike BOOST_FUSION_DEFINE_TPL_STRUCT,
- it can be used at class or namespace scope.
- [heading Synopsis]
- BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
- (template_param0)(template_param1)...,
- struct_name,
- (member_type0, member_name0)
- (member_type1, member_name1)
- ...
- )
- [heading Expression Semantics]
- The semantics of BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE are identical to those of
- BOOST_FUSION_DEFINE_TPL_STRUCT, with two differences:
- # BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE can be used at class or namespace scope,
- and thus does not take a namespace list parameter.
- # The structure generated by BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE has a base
- class, and is thus not POD in C++03.
- [heading Header]
- #include <boost/fusion/adapted/struct/define_struct_inline.hpp>
- #include <boost/fusion/include/define_struct_inline.hpp>
- [heading Example]
- // Any instantiated enclosing::employee is a Fusion sequence
- class enclosing
- {
- BOOST_FUSION_DEFINE_TPL_STRUCT(
- (Name)(Age), employee,
- (Name, name)
- (Age, age))
- };
- [endsect]
- [section:define_assoc_struct BOOST_FUSION_DEFINE_ASSOC_STRUCT]
- [heading Description]
- BOOST_FUSION_DEFINE_ASSOC_STRUCT is a macro that can be used to generate all the
- necessary boilerplate to define and adapt an arbitrary struct as a model of
- __random_access_sequence__ and __associative_sequence__.
- [heading Synopsis]
- BOOST_FUSION_DEFINE_ASSOC_STRUCT(
- (namespace0)(namespace1)...,
- struct_name,
- (member_type0, member_name0, key_type0)
- (member_type1, member_name1, key_type1)
- ...
- )
- [variablelist Notation
- [[`str`] [An instance of `struct_name`]]
- [[`e0`...`en`] [Heterogeneous values]]
- [[`fs`] [A __forward_sequence__]]
- ]
- [heading Expression Semantics]
- The above macro generates the necessary code that defines and adapts `struct_name`
- as a model of __random_access_sequence__ and __associative_sequence__.
- The sequence `(namespace0)(namespace1)...` declares the namespace
- for `struct_name`. It yields to a fully qualified name for `struct_name` of
- `namespace0::namespace1::... struct_name`.
- If an empty namespace sequence is given (that is a macro that expands to
- nothing), the struct is placed in the global namespace.
- The sequence of `(member_typeN, member_nameN, key_typeN)`
- triples declares the type, name and key type of each of the struct members
- that are part of the sequence.
- The macro should be used at global scope.
- Semantics of an expression is defined only where it differs from, or is not
- defined in __random_access_sequence__ and __associative_sequence__.
- [table
- [[Expression] [Semantics]]
- [[`struct_name()`] [Creates an instance of `struct_name` with default constructed elements.]]
- [[`struct_name(e0, e1,... en)`] [Creates an instance of `struct_name` with elements `e0`...`en`.]]
- [[`struct_name(fs)`] [Copy constructs an instance of `struct_name` from a __forward_sequence__ `fs`.]]
- [[`str = fs`] [Assigns from a __forward_sequence__ `fs`.]]
- [[`str.member_nameN`] [Access of struct member `member_nameN`]]
- ]
- [heading Header]
- #include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
- #include <boost/fusion/include/define_assoc_struct.hpp>
- [heading Example]
- namespace keys
- {
- struct name;
- struct age;
- }
- // demo::employee is a Fusion sequence
- BOOST_FUSION_DEFINE_ASSOC_STRUCT(
- (demo), employee,
- (std::string, name, keys::name)
- (int, age, keys::age))
- [endsect]
- [section:define_assoc_tpl_struct BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT]
- [heading Description]
- BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT is a macro that can be used to generate all
- the necessary boilerplate to define and adapt an arbitrary template struct as a
- model of __random_access_sequence__ and __associative_sequence__.
- [heading Synopsis]
- BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT(
- (template_param0)(template_param1)...,
- (namespace0)(namespace1)...,
- struct_name,
- (member_type0, member_name0, key_type0)
- (member_type1, member_name1, key_type1)
- ...
- )
- [variablelist Notation
- [[`Str`] [An instantiated `struct_name`]]
- [[`str`] [An instance of `Str`]]
- [[`e0`...`en`] [Heterogeneous values]]
- [[`fs`] [A __forward_sequence__]]
- ]
- [heading Expression Semantics]
- The above macro generates the necessary code that defines and adapts
- `struct_name` as a model of __random_access_sequence__ and
- __associative_sequence__.
- The sequence `(template_param0)(template_param1)...` declares the names of
- the template type parameters used.
- The sequence `(namespace0)(namespace1)...` declares the namespace
- for `struct_name`. It yields to a fully qualified name for `struct_name` of
- `namespace0::namespace1::... struct_name`.
- If an empty namespace sequence is given (that is a macro that expands to
- nothing), the struct is placed in the global namespace.
- The sequence of `(member_typeN, member_nameN, key_typeN)`
- triples declares the type, name and key type of each of the struct members
- that are part of the sequence.
- The macro should be used at global scope.
- Semantics of an expression is defined only where it differs from, or is not
- defined in __random_access_sequence__ and __associative_sequence__.
- [table
- [[Expression] [Semantics]]
- [[`Str()`] [Creates an instance of `Str` with default constructed elements.]]
- [[`Str(e0, e1,... en)`] [Creates an instance of `Str` with elements `e0`...`en`.]]
- [[`Str(fs)`] [Copy constructs an instance of `Str` from a __forward_sequence__ `fs`.]]
- [[`str = fs`] [Assigns from a __forward_sequence__ `fs`.]]
- [[`str.member_nameN`] [Access of struct member `member_nameN`]]
- ]
- [heading Header]
- #include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
- #include <boost/fusion/include/define_assoc_struct.hpp>
- [heading Example]
- namespace keys
- {
- struct name;
- struct age;
- }
- // Any instantiated demo::employee is a Fusion sequence
- BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT(
- (Name)(Age), (demo), employee,
- (Name, name, keys::name)
- (Age, age, keys::age))
- [endsect]
- [endsect]
|