mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 20:17:32 +02:00
documentation update
[SVN r61202]
This commit is contained in:
353
doc/adapted.qbk
353
doc/adapted.qbk
@ -196,11 +196,11 @@ __random_access_sequence__.
|
||||
The above macro generates the necessary code to adapt `struct_name`
|
||||
as a model of __random_access_sequence__.
|
||||
The sequence of `(member_typeN, member_nameN)`
|
||||
pairs declares the type and names of each of the struct members that will be
|
||||
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, and `struct_name` should be the fully
|
||||
namespace qualified name of the struct to be converted.
|
||||
namespace qualified name of the struct to be adapted.
|
||||
|
||||
[heading Header]
|
||||
|
||||
@ -247,16 +247,16 @@ 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 parameter used.
|
||||
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)`
|
||||
pairs declares the type and names of each of the struct members that will be
|
||||
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, and `struct_name` should be the fully
|
||||
namespace qualified name of the struct to be converted.
|
||||
namespace qualified name of the struct to be adapted.
|
||||
|
||||
[heading Header]
|
||||
|
||||
@ -276,7 +276,8 @@ namespace qualified name of the struct to be converted.
|
||||
|
||||
// Any instantiated demo::employee is now a Fusion sequence
|
||||
BOOST_FUSION_ADAPT_TPL_STRUCT(
|
||||
(Name)(Age), (demo::employee)(Name)(Age),
|
||||
(Name)(Age),
|
||||
(demo::employee) (Name)(Age),
|
||||
(Name, name)
|
||||
(Age, age))
|
||||
|
||||
@ -299,7 +300,9 @@ adapted using the given name.
|
||||
)
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(
|
||||
struct_name, namespace_list, adapted_name,
|
||||
struct_name,
|
||||
(namespace0)(namespace1)...,
|
||||
adapted_name,
|
||||
(member_type0, member_name0)
|
||||
(member_type1, member_name1)
|
||||
...
|
||||
@ -309,17 +312,19 @@ adapted using the given name.
|
||||
|
||||
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 of `(member_typeN, member_nameN)`
|
||||
pairs declares the type and names of each of the struct members that will be
|
||||
part of the sequence. `namespace_list` specifies the C++ namespace of
|
||||
the `adapted_name`. It has the format of `(ns1)(ns2)...`, which results in
|
||||
a fully qualified adapted name of `ns1::ns2::adapted_name`.
|
||||
If an empty `namespace_list` is given, the adapted view is placed in the global
|
||||
namespace.
|
||||
If no namespace list is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_NAMED`), 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, 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_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, and `struct_name` should be the fully
|
||||
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]
|
||||
@ -367,10 +372,10 @@ 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)`
|
||||
triples declares the type, name and key type of each of the struct members
|
||||
that will be part of the sequence.
|
||||
that are part of the sequence.
|
||||
|
||||
The macro should be used at global scope, and `struct_name` should be the fully
|
||||
namespace qualified name of the struct to be converted.
|
||||
namespace qualified name of the struct to be adapted.
|
||||
|
||||
[heading Header]
|
||||
|
||||
@ -425,16 +430,16 @@ 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 parameter used.
|
||||
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)`
|
||||
triples declares the type, name and key type of each of the struct members
|
||||
that will be part of the sequence.
|
||||
that are part of the sequence.
|
||||
|
||||
The macro should be used at global scope, and `struct_name` should be the fully
|
||||
namespace qualified name of the struct to be converted.
|
||||
namespace qualified name of the struct to be adapted.
|
||||
|
||||
[heading Header]
|
||||
|
||||
@ -462,7 +467,8 @@ namespace qualified name of the struct to be converted.
|
||||
// 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)(Age),
|
||||
(demo::employee) (Name)(Age),
|
||||
(Name, name, keys::name)
|
||||
(Age, age, keys::age))
|
||||
|
||||
@ -485,7 +491,9 @@ __associative_sequence__. The given struct is adapted using the given name.
|
||||
)
|
||||
|
||||
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS(
|
||||
struct_name, namespace_list, adapted_name,
|
||||
struct_name,
|
||||
(namespace0)(namespace1)...,
|
||||
adapted_name,
|
||||
(member_type0, member_name0, key_type0)
|
||||
(member_type1, member_name1, key_type1)
|
||||
...
|
||||
@ -496,18 +504,18 @@ __associative_sequence__. The given struct is adapted using the given name.
|
||||
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, 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 will be part of the sequence.
|
||||
`namespace_list` specifies the C++ namespace of the `adapted_name`.
|
||||
It has the format of `(ns1)(ns2)...`, which results in a fully qualified adapted
|
||||
name of `ns1::ns2::adapted_name`.
|
||||
If an empty `namespace_list` is given, the adapted view is placed in the global
|
||||
namespace.
|
||||
If no namespace list is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_ASSOC_NAMED`),
|
||||
the adapted view is placed in the namespace `boost::fusion::adapted`.
|
||||
that are part of the sequence.
|
||||
|
||||
The macro should be used at global scope, and `struct_name` should be the fully
|
||||
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]
|
||||
@ -540,4 +548,285 @@ namespace qualified name of the struct to be converted.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:define_struct BOOST_FUSION_DEFINE_STRUCT]
|
||||
|
||||
[heading Description]
|
||||
|
||||
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, 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(
|
||||
(namespace0)(namespace1)...,
|
||||
(template_param0)(template_param1)...,
|
||||
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 `(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, the struct is placed in the
|
||||
global namespace.
|
||||
The sequence `(template_param0)(template_param1)...` declares the names of
|
||||
the template type parameters used.
|
||||
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(
|
||||
(demo), (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, 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(
|
||||
(namespace0)(namespace1)...,
|
||||
(template_param0)(template_param1)...,
|
||||
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 `(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, the struct is placed in the
|
||||
global namespace.
|
||||
The sequence `(template_param0)(template_param1)...` declares the names of
|
||||
the template type parameters used.
|
||||
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(
|
||||
(demo), (Name)(Age), employee,
|
||||
(Name, name, keys::name)
|
||||
(Age, age, keys::age))
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
Reference in New Issue
Block a user