diff --git a/changelist.txt b/changelist.txt
index 608b3c92..1e862f43 100644
--- a/changelist.txt
+++ b/changelist.txt
@@ -15,4 +15,6 @@ Interface Changes
BOOST_FUSION_DEFINE_TPL_STRUCT, BOOST_FUSION_DEFINE_ASSOC_STRUCT and
BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT
- June 18, 2010: Added reverse_fold, iter_fold and reverse_iter_fold. Fixes
- Boost Trac Ticket #1623.
\ No newline at end of file
+ Boost Trac Ticket #1623.
+- October 7, 2010: Added BOOST_FUSION_ADAPT_ADT, BOOST_FUSION_ADAPT_ASSOC_ADT,
+ BOOST_FUSION_ADAPT_TPL_ADT and BOOST_FUSION_ADAPT_ASSOC_TPL_ADT
\ No newline at end of file
diff --git a/doc/adapted.qbk b/doc/adapted.qbk
index de658573..262671a3 100644
--- a/doc/adapted.qbk
+++ b/doc/adapted.qbk
@@ -592,6 +592,9 @@ 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 struct to be converted.
+
[heading Header]
#include
@@ -638,7 +641,340 @@ is [^attribute_type['N]] with const-qualifier and reference removed.
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;
+ 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_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.
+[^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 struct to be converted.
+
+[heading Header]
+
+ #include
+ #include
+
+[heading Example]
+ namespace demo
+ {
+ template
+ 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 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.
+[^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 struct to be converted.
+
+[heading Header]
+
+ #include
+ #include
+
+[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,
+ (std::string const&, std::string const&, obj.get_name(), obj.set_name(val), keys::name)
+ (int, int, obj.get_age(), obj.set_age(val), keys::age))
+
+ demo::employee e;
+ at_key(e)="Edward Norton";
+ at_key(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.
+[^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 struct to be converted.
+
+[heading Header]
+
+ #include
+ #include
+
+[heading Example]
+ namespace demo
+ {
+ template
+ 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 e;
+ at_key(e)="Edward Norton";
+ at_key(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]
diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk
index 46f1557a..d60df5fc 100644
--- a/doc/algorithm.qbk
+++ b/doc/algorithm.qbk
@@ -1,5 +1,6 @@
[/==============================================================================
Copyright (C) 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger
+ 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
@@ -91,7 +92,7 @@ the first call) and [arg_desc] of `seq`.
[[Parameter][Requirement][Description]]
[[`seq`][A model of seq_concept_macro][Operation's argument]]
[[`initial_state`][Any type][Initial state]]
- [[`f`][`f(s,arg_id_macro)` with return type `__boost_result_of_call__::type` must be a valid expression for current state `s` of type `S`, and for each invoke_desc_macro][Operation's argument]]
+ [[`f`][`f(s,arg_id_macro)` with return type `__boost_result_of_call__::type` for current state `s` of type `S`, and for each invoke_desc_macro][Operation's argument]]
]
[heading Expression Semantics]
diff --git a/doc/changelog.qbk b/doc/changelog.qbk
index ca301a2a..67a65d0e 100644
--- a/doc/changelog.qbk
+++ b/doc/changelog.qbk
@@ -1,5 +1,6 @@
[/==============================================================================
Copyright (C) 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger
+ 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
@@ -34,6 +35,8 @@ This section summarizes significant changes to the Fusion library.
__define_assoc_struct__ and __define_assoc_tpl_struct__ (Christopher Schmidt)
* June 18, 2010: Added __reverse_fold__, __iter_fold__ and __reverse_iter_fold__
(Christopher Schmidt)
-
+* October 7, 2010: Added __adapt_adt__, __adapt_tpl_adt__,
+ __adapt_assoc_adt__ and __adapt_assoc_tpl_adt__ (Joel de Guzman,
+ Hartmut Kaiser and Christopher Schmidt)
[endsect]
diff --git a/doc/fusion.qbk b/doc/fusion.qbk
index a24f3adc..50892d7d 100644
--- a/doc/fusion.qbk
+++ b/doc/fusion.qbk
@@ -1,5 +1,6 @@
[/==============================================================================
Copyright (C) 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger
+ 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
@@ -138,6 +139,9 @@
[def __adapt_assoc_struct_named__ [link fusion.adapted.adapt_assoc_struct_named `BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED`]]
[def __adapt_assoc_struct_named_ns__ [link fusion.adapted.adapt_assoc_struct_named `BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS`]]
[def __adapt_adt__ [link fusion.adapted.adapt_adt `BOOST_FUSION_ADAPT_ADT`]]
+[def __adapt_tpl_adt__ [link fusion.adapted.adapt_tpl_adt `BOOST_FUSION_ADAPT_TPL_ADT`]]
+[def __adapt_assoc_adt__ [link fusion.adapted.adapt_assoc_adt `BOOST_FUSION_ADAPT_ASSOC_ADT`]]
+[def __adapt_assoc_tpl_adt__ [link fusion.adapted.adapt_assoc_tpl_adt `BOOST_FUSION_ADAPT_ASSOC_TPL_ADT`]]
[def __define_struct__ [link fusion.adapted.define_struct `BOOST_FUSION_DEFINE_STRUCT`]]
[def __define_tpl_struct__ [link fusion.adapted.define_tpl_struct `BOOST_FUSION_DEFINE_TPL_STRUCT`]]
[def __define_assoc_struct__ [link fusion.adapted.define_assoc_struct `BOOST_FUSION_DEFINE_ASSOC_STRUCT`]]
diff --git a/doc/html/fusion/adapted.html b/doc/html/fusion/adapted.html
index bc87e4f8..14543404 100644
--- a/doc/html/fusion/adapted.html
+++ b/doc/html/fusion/adapted.html
@@ -39,6 +39,9 @@
namespacedemo
@@ -134,10 +138,10 @@
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;
+std::cout<<e.get_name()<<" is "<<e.get_age()<<" years old"<<std::endl;