Removing AUTO_ADAPT_STRUCT_NAMED, AUTO_ADAPT_ASSOC_STRUCT and AUTO_ADAPT_ASSOC_STRUCT_NAMED.

As discussed with Agustín Bergé and Joel de Guzman on https://github.com/boostorg/fusion/pull/3,
it's better to remove the separate macro for the type deducting macros, and
to instead support a flexible API allowing backward compatibility and type
omission.

This is what ADAPT_STRUCT and ADAPT_STRUCT_TPL now provides. All other
macros will be improved in the same way in the following commits.
This commit is contained in:
Damien Buhl (alias daminetreg)
2014-06-11 01:19:00 +02:00
parent 6483cf4058
commit 0000ca263b

View File

@ -328,7 +328,7 @@ namespace qualified name of the struct to be adapted.
[endsect] [endsect]
[section:adapt_struct_named BOOST_FUSION_ \[AUTO_\] ADAPT_STRUCT_NAMED] [section:adapt_struct_named BOOST_FUSION_ADAPT_STRUCT_NAMED]
[heading Description] [heading Description]
BOOST_FUSION_ADAPT_STRUCT_NAMED and BOOST_FUSION_ADAPT_STRUCT_NAMED_NS are BOOST_FUSION_ADAPT_STRUCT_NAMED and BOOST_FUSION_ADAPT_STRUCT_NAMED_NS are
@ -336,7 +336,6 @@ 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 arbitrary struct a model of __random_access_sequence__. The given struct is
adapted using the given name. adapted using the given name.
[heading Synopsis] [heading Synopsis]
BOOST_FUSION_ADAPT_STRUCT_NAMED( BOOST_FUSION_ADAPT_STRUCT_NAMED(
struct_name, adapted_name, struct_name, adapted_name,
@ -345,13 +344,6 @@ adapted using the given name.
... ...
) )
BOOST_FUSION_AUTO_ADAPT_STRUCT_NAMED(
struct_name, adapted_name,
(member_name0)
(member_name1)
...
)
BOOST_FUSION_ADAPT_STRUCT_NAMED_NS( BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(
struct_name, struct_name,
(namespace0)(namespace1)..., (namespace0)(namespace1)...,
@ -361,17 +353,6 @@ adapted using the given name.
... ...
) )
BOOST_FUSION_AUTO_ADAPT_STRUCT_NAMED_NS(
struct_name,
(namespace0)(namespace1)...,
adapted_name,
(member_name0)
(member_name1)
...
)
[heading Semantics] [heading Semantics]
The above macros generate the necessary code to adapt `struct_name` The above macros generate the necessary code to adapt `struct_name`
@ -384,11 +365,9 @@ If an empty namespace sequence is given (that is a macro that expands to
nothing), the adapted view is placed in the global namespace. nothing), the adapted view is placed in the global namespace.
If no namespace sequence is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_NAMED`), the If no namespace sequence is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_NAMED`), the
adapted view is placed in the namespace `boost::fusion::adapted`. adapted view is placed in the namespace `boost::fusion::adapted`.
In the non-auto version of the macro the sequence of The sequence of `(member_typeN, member_nameN)`
`(member_typeN, member_nameN)` pairs declares the type and names of each of the pairs declares the type and names of each of the struct members that are
struct members that are part of the sequence. part of the sequence.
While the auto version of the macro only allows specifying a sequence of
`(member_nameN)` as fields' types are deduced with [@boost:/libs/typeof/index.html Boost.TypeOf].
The macros 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. namespace qualified name of the struct to be converted.
@ -396,10 +375,9 @@ namespace qualified name of the struct to be converted.
[heading Header] [heading Header]
#include <boost/fusion/adapted/struct/adapt_struct_named.hpp> #include <boost/fusion/adapted/struct/adapt_struct_named.hpp>
#include <boost/fusion/adapted/struct/auto_adapt_struct_named.hpp>
#include <boost/fusion/include/adapt_struct_named.hpp> #include <boost/fusion/include/adapt_struct_named.hpp>
[heading Example: BOOST_FUSION_ADAPT_STRUCT_NAMED] [heading Example]
namespace demo namespace demo
{ {
struct employee struct employee
@ -416,26 +394,9 @@ namespace qualified name of the struct to be converted.
(std::string, name) (std::string, name)
(int, age)) (int, age))
[heading Example: BOOST_FUSION_AUTO_ADAPT_STRUCT_NAMED]
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_AUTO_ADAPT_STRUCT_NAMED(
demo::employee, adapted_employee,
(name)
(age))
[endsect] [endsect]
[section:adapt_assoc BOOST_FUSION_ \[AUTO_\] ADAPT_ASSOC_STRUCT] [section:adapt_assoc BOOST_FUSION_ADAPT_ASSOC_STRUCT]
[heading Description] [heading Description]
BOOST_FUSION_ADAPT_ASSOC_STRUCT is a macro that can be used to generate all the BOOST_FUSION_ADAPT_ASSOC_STRUCT is a macro that can be used to generate all the
@ -450,24 +411,13 @@ __random_access_sequence__ and __associative_sequence__.
... ...
) )
BOOST_FUSION_AUTO_ADAPT_ASSOC_STRUCT(
struct_name,
(member_name0, key_type0)
(member_name1, key_type1)
...
)
[heading Semantics] [heading Semantics]
The above macro generates the necessary code to adapt `struct_name` The above macro generates the necessary code to adapt `struct_name`
as a model of __random_access_sequence__ and __associative_sequence__. as a model of __random_access_sequence__ and __associative_sequence__.
The sequence of `(member_typeN, member_nameN, key_typeN)` The sequence of `(member_typeN, member_nameN, key_typeN)`
triples declares the type, name and key type of each of the struct members triples declares the type, name and key type of each of the struct members
that are part of the sequence. that are part of the sequence.
While BOOST_FUSION_AUTO_ADAPT_ASSOC_STRUCT only allows specifying a sequence of
`(member_nameN, key_typeN)` as fields' types are deduced with
[@boost:/libs/typeof/index.html Boost.TypeOf].
The macro should be used at global scope, and `struct_name` should be the fully The macro should be used at global scope, and `struct_name` should be the fully
namespace qualified name of the struct to be adapted. namespace qualified name of the struct to be adapted.
@ -475,10 +425,9 @@ namespace qualified name of the struct to be adapted.
[heading Header] [heading Header]
#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp> #include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
#include <boost/fusion/adapted/struct/auto_adapt_assoc_struct.hpp>
#include <boost/fusion/include/adapt_assoc_struct.hpp> #include <boost/fusion/include/adapt_assoc_struct.hpp>
[heading Example : BOOST_FUSION_ADAPT_ASSOC_STRUCT] [heading Example]
namespace demo namespace demo
{ {
struct employee struct employee
@ -502,30 +451,6 @@ namespace qualified name of the struct to be adapted.
(std::string, name, keys::name) (std::string, name, keys::name)
(int, age, keys::age)) (int, age, keys::age))
[heading Example : BOOST_FUSION_AUTO_ADAPT_ASSOC_STRUCT]
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_AUTO_ADAPT_ASSOC_STRUCT(
demo::employee,
(name, keys::name)
(age, keys::age))
[endsect] [endsect]
[section:adapt_assoc_tpl_struct BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT] [section:adapt_assoc_tpl_struct BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT]
@ -594,7 +519,7 @@ namespace qualified name of the struct to be adapted.
[endsect] [endsect]
[section:adapt_assoc_struct_named BOOST_FUSION_ \[AUTO_\] ADAPT_ASSOC_STRUCT_NAMED] [section:adapt_assoc_struct_named BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED]
[heading Description] [heading Description]
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED and BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS are BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED and BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS are
@ -610,13 +535,6 @@ __associative_sequence__. The given struct is adapted using the given name.
... ...
) )
BOOST_FUSION_AUTO_ADAPT_ASSOC_STRUCT_NAMED(
struct_name, adapted_name,
(member_name0, key_type0)
(member_name1, key_type1)
...
)
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS( BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS(
struct_name, struct_name,
(namespace0)(namespace1)..., (namespace0)(namespace1)...,
@ -626,15 +544,6 @@ __associative_sequence__. The given struct is adapted using the given name.
... ...
) )
BOOST_FUSION_AUTO_ADAPT_ASSOC_STRUCT_NAMED_NS(
struct_name,
(namespace0)(namespace1)...,
adapted_name,
(member_name0, key_type0)
(member_name1, key_type1)
...
)
[heading Semantics] [heading Semantics]
The above macros generate the necessary code to adapt `struct_name` The above macros generate the necessary code to adapt `struct_name`
@ -651,20 +560,15 @@ The sequence of `(member_typeN, member_nameN, key_typeN)`
triples declares the type, name and key type of each of the struct members triples declares the type, name and key type of each of the struct members
that are part of the sequence. that are part of the sequence.
While BOOST_FUSION_AUTO_ADAPT_ASSOC_STRUCT_NAMED only allows specifying a
sequence of `(member_nameN, key_typeN)` as fields' types are deduced with
[@boost:/libs/typeof/index.html Boost.TypeOf].
The macros 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. namespace qualified name of the struct to be converted.
[heading Header] [heading Header]
#include <boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp> #include <boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp>
#include <boost/fusion/adapted/struct/auto_adapt_assoc_struct_named.hpp>
#include <boost/fusion/include/adapt_assoc_struct_named.hpp> #include <boost/fusion/include/adapt_assoc_struct_named.hpp>
[heading Example : BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED] [heading Example]
namespace demo namespace demo
{ {
struct employee struct employee
@ -687,29 +591,6 @@ namespace qualified name of the struct to be converted.
(std::string, name, keys::name) (std::string, name, keys::name)
(int, age, keys::age)) (int, age, keys::age))
[heading Example : BOOST_FUSION_AUTO_ADAPT_ASSOC_STRUCT_NAMED]
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_AUTO_ADAPT_ASSOC_STRUCT_NAMED(
demo::employee, adapted_employee,
(name, keys::name)
(age, keys::age))
[endsect] [endsect]
[section:adapt_adt BOOST_FUSION_ADAPT_ADT] [section:adapt_adt BOOST_FUSION_ADAPT_ADT]