From 0000ca263b29868f66afe8cd5e3e9bc27e93ec15 Mon Sep 17 00:00:00 2001 From: "Damien Buhl (alias daminetreg)" Date: Wed, 11 Jun 2014 01:19:00 +0200 Subject: [PATCH] Removing AUTO_ADAPT_STRUCT_NAMED, AUTO_ADAPT_ASSOC_STRUCT and AUTO_ADAPT_ASSOC_STRUCT_NAMED. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- doc/adapted.qbk | 139 ++++-------------------------------------------- 1 file changed, 10 insertions(+), 129 deletions(-) diff --git a/doc/adapted.qbk b/doc/adapted.qbk index f3e74367..10e88c71 100644 --- a/doc/adapted.qbk +++ b/doc/adapted.qbk @@ -328,7 +328,7 @@ namespace qualified name of the struct to be adapted. [endsect] -[section:adapt_struct_named BOOST_FUSION_ \[AUTO_\] ADAPT_STRUCT_NAMED] +[section:adapt_struct_named BOOST_FUSION_ADAPT_STRUCT_NAMED] [heading Description] 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 adapted using the given name. - [heading Synopsis] BOOST_FUSION_ADAPT_STRUCT_NAMED( 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( struct_name, (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] 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. If no namespace sequence is given (i.e. `BOOST_FUSION_ADAPT_STRUCT_NAMED`), the adapted view is placed in the namespace `boost::fusion::adapted`. -In the non-auto version of the macro 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. -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 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 macros should be used at global scope, and `struct_name` should be the fully namespace qualified name of the struct to be converted. @@ -396,10 +375,9 @@ namespace qualified name of the struct to be converted. [heading Header] #include - #include #include -[heading Example: BOOST_FUSION_ADAPT_STRUCT_NAMED] +[heading Example] namespace demo { struct employee @@ -416,26 +394,9 @@ namespace qualified name of the struct to be converted. (std::string, name) (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] -[section:adapt_assoc BOOST_FUSION_ \[AUTO_\] ADAPT_ASSOC_STRUCT] +[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 @@ -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] 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 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]. +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 adapted. @@ -475,10 +425,9 @@ namespace qualified name of the struct to be adapted. [heading Header] #include - #include #include -[heading Example : BOOST_FUSION_ADAPT_ASSOC_STRUCT] +[heading Example] namespace demo { struct employee @@ -502,30 +451,6 @@ namespace qualified name of the struct to be adapted. (std::string, name, keys::name) (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] [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] -[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] 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( struct_name, (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] 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 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 namespace qualified name of the struct to be converted. [heading Header] #include - #include #include -[heading Example : BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED] +[heading Example] namespace demo { struct employee @@ -687,29 +591,6 @@ namespace qualified name of the struct to be converted. (std::string, name, keys::name) (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] [section:adapt_adt BOOST_FUSION_ADAPT_ADT]