Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65446 - in sandbox/SOC/2009/fusion: boost/fusion/adapted/detail/adt boost/fusion/adapted/detail/struct boost/fusion/algorithm/iteration/detail boost/fusion/algorithm/query/detail boost/fusion/support libs/fusion/test/suite1/sequence
From: mr.chr.schmidt_at_[hidden]
Date: 2010-09-17 17:59:05


Author: cschmidt
Date: 2010-09-17 17:59:03 EDT (Fri, 17 Sep 2010)
New Revision: 65446
URL: http://svn.boost.org/trac/boost/changeset/65446

Log:
adt_attribute_proxy refactorization
Text files modified:
   sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/adt/adapt_base.hpp | 73 ++++++++++++++++++++++++++++++---------
   sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/struct/define_struct.hpp | 19 ++++++++-
   sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/struct/extension.hpp | 7 ++-
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each.hpp | 6 +--
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/all.hpp | 54 ++++++++++++++++++++++-------
   sandbox/SOC/2009/fusion/boost/fusion/support/config.hpp | 2
   sandbox/SOC/2009/fusion/libs/fusion/test/suite1/sequence/adapt_adt.cpp | 14 +++++++
   7 files changed, 135 insertions(+), 40 deletions(-)

Modified: sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/adt/adapt_base.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/adt/adapt_base.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/adt/adapt_base.hpp 2010-09-17 17:59:03 EDT (Fri, 17 Sep 2010)
@@ -15,6 +15,7 @@
 #include <boost/preprocessor/seq/elem.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/type_traits/is_const.hpp>
+#include <boost/utility/addressof.hpp>
 
 #define BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_TEMPLATE_IMPL(TEMPLATE_PARAMS_SEQ) \
     typename detail::get_identity< \
@@ -33,7 +34,39 @@
     template< \
         BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
- struct access::adt_attribute_proxy< \
+ struct access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ > \
+ { \
+ template<class Arg> \
+ static void \
+ boost_fusion_adapt_adt_impl_set( \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj, \
+ BOOST_FUSION_R_ELSE_CLREF(Arg) val) \
+ { \
+ BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 3, ATTRIBUTE); \
+ } \
+ \
+ static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \
+ boost_fusion_adapt_adt_impl_get( \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj) \
+ { \
+ return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \
+ } \
+ \
+ static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) \
+ boost_fusion_adapt_adt_impl_get( \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& obj) \
+ { \
+ return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \
+ } \
+ }; \
+ \
+ template< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
+ > \
+ struct adt_attribute_proxy< \
         BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
       , I \
       , true \
@@ -43,25 +76,25 @@
                                                                                 \
         explicit \
         adt_attribute_proxy( \
- BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& o) \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const*const o) \
           : obj(o) \
         {} \
                                                                                 \
         operator type() const \
         { \
- return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \
+ return access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ >::boost_fusion_adapt_adt_impl_get(*obj); \
         } \
                                                                                 \
- BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& obj; \
- \
- private: \
- adt_attribute_proxy& operator= (adt_attribute_proxy const&); \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const* obj; \
     }; \
                                                                                 \
     template< \
         BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
- struct access::adt_attribute_proxy< \
+ struct adt_attribute_proxy< \
         BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
       , I \
       , false \
@@ -70,27 +103,33 @@
         typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \
                                                                                 \
         explicit \
- adt_attribute_proxy(BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& o) \
+ adt_attribute_proxy( \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)*const o) \
           : obj(o) \
         {} \
                                                                                 \
         template<class Arg> \
         adt_attribute_proxy& \
- operator=(Arg const& val) \
+ operator=(BOOST_FUSION_R_ELSE_CLREF(Arg) val) \
         { \
- BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 3, ATTRIBUTE); \
+ access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ >::boost_fusion_adapt_adt_impl_set( \
+ *obj, \
+ BOOST_FUSION_FORWARD(Arg,val)); \
             return *this; \
         } \
                                                                                 \
         operator type() const \
         { \
- return BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 2, ATTRIBUTE); \
+ return access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ >::boost_fusion_adapt_adt_impl_get(*obj); \
         } \
                                                                                 \
- BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \
- \
- private: \
- adt_attribute_proxy& operator= (adt_attribute_proxy const&); \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)* obj; \
     }; \
                                                                                 \
     template< \
@@ -129,7 +168,7 @@
             static type \
             call(SeqRef obj) \
             { \
- return type(obj); \
+ return type(boost::addressof(obj)); \
             } \
         }; \
     };

Modified: sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/struct/define_struct.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/struct/define_struct.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/struct/define_struct.hpp 2010-09-17 17:59:03 EDT (Fri, 17 Sep 2010)
@@ -62,8 +62,9 @@
             BOOST_PP_TUPLE_ELEM(3,1,DATA)) \
     {}
 
-#define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I( \
- R, ATTRIBUTE_TUPEL_SIZE, I_, ATTRIBUTE) \
+#ifdef BOOST_NO_AUTO_DECLARATIONS
+# define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I( \
+ R, ATTRIBUTE_TUPEL_SIZE, I_, ATTRIBUTE) \
                                                                                 \
     BOOST_PP_EXPR_IF( \
         I_, \
@@ -72,11 +73,23 @@
                 BOOST_PP_CAT(I,BOOST_PP_DEC(I_))& \
>::type \
         BOOST_PP_CAT(I,I_); \
- BOOST_PP_CAT(I,I_) BOOST_PP_CAT(i,I_)= \
+ BOOST_PP_CAT(I,I_) const BOOST_PP_CAT(i,I_)= \
             boost::fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(I_)));) \
                                                                                 \
     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)= \
         boost::fusion::deref(BOOST_PP_CAT(i,I_));
+#else
+# define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I( \
+ R, ATTRIBUTE_TUPEL_SIZE, I_, ATTRIBUTE) \
+ \
+ BOOST_PP_EXPR_IF( \
+ I_, \
+ auto const BOOST_PP_CAT(i,I_)= \
+ boost::fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(I_)));) \
+ \
+ BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE)= \
+ boost::fusion::deref(BOOST_PP_CAT(i,I_));
+#endif
 
 #define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_OP( \
     ATTRIBUTES_SEQ, ATTRIBUTE_TUPEL_SIZE) \

Modified: sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/struct/extension.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/struct/extension.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/struct/extension.hpp 2010-09-17 17:59:03 EDT (Fri, 17 Sep 2010)
@@ -31,10 +31,13 @@
             template<typename Seq, int N>
             struct struct_member;
 
- template<typename T, int N, bool Const>
- struct adt_attribute_proxy;
+ template<typename Seq, int N>
+ struct adt_attribute_access;
         };
 
+ template <typename T, int N, bool Const>
+ struct adt_attribute_proxy;
+
         template<typename Seq, int N>
         struct struct_member_name;
 

Modified: sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each.hpp 2010-09-17 17:59:03 EDT (Fri, 17 Sep 2010)
@@ -21,7 +21,6 @@
 #include <boost/preprocessor/arithmetic/inc.hpp>
 #include <boost/preprocessor/comparison/equal.hpp>
 #include <boost/preprocessor/comparison/not_equal.hpp>
-#include <boost/preprocessor/control/expr_if.hpp>
 #include <boost/preprocessor/control/expr_iif.hpp>
 #include <boost/preprocessor/tuple/eat.hpp>
 #include <boost/preprocessor/repetition/repeat.hpp>
@@ -73,15 +72,14 @@
     { \
         template<typename It0, typename F> \
         static void \
- call( \
- It0 const& BOOST_PP_EXPR_IF(N_,it0), \
- BOOST_FUSION_RREF_ELSE_OBJ(F) BOOST_PP_EXPR_IF(N_,f)) \
+ call(It0 const& it0,BOOST_FUSION_RREF_ELSE_OBJ(F) f) \
         { \
             BOOST_PP_REPEAT( \
                 BOOST_PP_DEC(N_), \
                 BOOST_FUSION_UNROLLED_FOR_EACH_IMPL_N,_) \
                                                                                 \
             f(fusion::deref(BOOST_PP_CAT(it,BOOST_PP_DEC(N_)))); \
+ \
             BOOST_PP_IIF( \
                 BOOST_PP_EQUAL(N_,BOOST_FUSION_UNROLLED_DEPTH), \
                 BOOST_FUSION_UNROLLED_FOR_EACH_IMPL_NEXT, \

Modified: sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/all.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/all.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/all.hpp 2010-09-17 17:59:03 EDT (Fri, 17 Sep 2010)
@@ -21,17 +21,29 @@
 #include <boost/preprocessor/arithmetic/inc.hpp>
 #include <boost/preprocessor/comparison/equal.hpp>
 #include <boost/preprocessor/comparison/not_equal.hpp>
-#include <boost/preprocessor/control/expr_if.hpp>
 #include <boost/preprocessor/control/expr_iif.hpp>
 #include <boost/preprocessor/tuple/eat.hpp>
 #include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
 
 namespace boost { namespace fusion { namespace detail
 {
     template<int N>
     struct unrolled_all;
 
-#define BOOST_FUSION_UNROLLED_ALL_IMPL_N(Z,N,_) \
+ template<>
+ struct unrolled_all<0>
+ {
+ template<typename It0, typename F>
+ static bool
+ call(It0 const&,BOOST_FUSION_RREF_ELSE_OBJ(F))
+ {
+ return true;
+ }
+ };
+
+#ifdef BOOST_NO_AUTO_DECLARATIONS
+# define BOOST_FUSION_UNROLLED_ALL_IMPL_N(Z,N,_) \
     if(!f(fusion::deref(BOOST_PP_CAT(it,N)))) \
     { \
         return false; \
@@ -42,39 +54,55 @@
     BOOST_PP_CAT(It,BOOST_PP_INC(N)); \
     BOOST_PP_CAT(It,BOOST_PP_INC(N)) const BOOST_PP_CAT(it,BOOST_PP_INC(N))( \
         fusion::next(BOOST_PP_CAT(it,N)));
+#else
+# define BOOST_FUSION_UNROLLED_ALL_IMPL_N(Z,N,_) \
+ if(!f(fusion::deref(BOOST_PP_CAT(it,N)))) \
+ { \
+ return false; \
+ } \
+ \
+ auto const BOOST_PP_CAT(it,BOOST_PP_INC(N))( \
+ fusion::next(BOOST_PP_CAT(it,N)));
+#endif
 
-#define BOOST_FUSION_UNROLLED_ALL_IMPL_LAST(_) true;
+#define BOOST_FUSION_UNROLLED_ALL_IMPL_LAST(_) true
 
 #define BOOST_FUSION_UNROLLED_ALL_IMPL_NEXT(N_) \
     unrolled_all<N-BOOST_FUSION_UNROLLED_DEPTH>::call( \
         fusion::next(BOOST_PP_CAT(it,BOOST_PP_DEC(N_))), \
- BOOST_FUSION_FORWARD(F,f));
+ BOOST_FUSION_FORWARD(F,f))
 
 #define BOOST_FUSION_UNROLLED_ALL_IMPL(Z,N_,_) \
     template<BOOST_PP_EXPR_IIF( \
- BOOST_PP_EQUAL(BOOST_PP_INC(N_),BOOST_FUSION_UNROLLED_DEPTH), int N) \
+ BOOST_PP_EQUAL(N_,BOOST_FUSION_UNROLLED_DEPTH), int N) \
> \
     struct unrolled_all \
     BOOST_PP_EXPR_IIF( \
- BOOST_PP_NOT_EQUAL(BOOST_PP_INC(N_),BOOST_FUSION_UNROLLED_DEPTH), <N_>) \
+ BOOST_PP_NOT_EQUAL(N_,BOOST_FUSION_UNROLLED_DEPTH), <N_>) \
     { \
         template<typename It0, typename F> \
         static bool \
- call( \
- It0 const& BOOST_PP_EXPR_IF(N_,it0), \
- BOOST_FUSION_RREF_ELSE_OBJ(F) BOOST_PP_EXPR_IF(N_,f)) \
+ call(It0 const& it0,BOOST_FUSION_RREF_ELSE_OBJ(F) f) \
         { \
- BOOST_PP_REPEAT(N_,BOOST_FUSION_UNROLLED_ALL_IMPL_N,_) \
+ BOOST_PP_REPEAT( \
+ BOOST_PP_DEC(N_), \
+ BOOST_FUSION_UNROLLED_ALL_IMPL_N,_) \
+ \
+ if(!f(fusion::deref(BOOST_PP_CAT(it,BOOST_PP_DEC(N_))))) \
+ { \
+ return false; \
+ } \
                                                                                 \
             return BOOST_PP_IIF( \
                 BOOST_PP_EQUAL(N_,BOOST_FUSION_UNROLLED_DEPTH), \
                 BOOST_FUSION_UNROLLED_ALL_IMPL_NEXT, \
- BOOST_FUSION_UNROLLED_ALL_IMPL_LAST)(N); \
+ BOOST_FUSION_UNROLLED_ALL_IMPL_LAST)(N_); \
         } \
     };
 
- BOOST_PP_REPEAT(
- BOOST_FUSION_UNROLLED_DEPTH,
+ BOOST_PP_REPEAT_FROM_TO(
+ 1,
+ BOOST_PP_INC(BOOST_FUSION_UNROLLED_DEPTH),
         BOOST_FUSION_UNROLLED_ALL_IMPL,
         _)
 

Modified: sandbox/SOC/2009/fusion/boost/fusion/support/config.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/support/config.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/support/config.hpp 2010-09-17 17:59:03 EDT (Fri, 17 Sep 2010)
@@ -9,7 +9,7 @@
 #define BOOST_FUSION_SUPPORT_CONFIG_HPP
 
 #ifndef BOOST_FUSION_UNROLLED_DEPTH
-# define BOOST_FUSION_UNROLLED_DEPTH 4
+# define BOOST_FUSION_UNROLLED_DEPTH 6
 #endif
 
 #endif

Modified: sandbox/SOC/2009/fusion/libs/fusion/test/suite1/sequence/adapt_adt.cpp
==============================================================================
--- sandbox/SOC/2009/fusion/libs/fusion/test/suite1/sequence/adapt_adt.cpp (original)
+++ sandbox/SOC/2009/fusion/libs/fusion/test/suite1/sequence/adapt_adt.cpp 2010-09-17 17:59:03 EDT (Fri, 17 Sep 2010)
@@ -28,6 +28,7 @@
 #include <boost/mpl/front.hpp>
 #include <boost/mpl/is_sequence.hpp>
 #include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
 #include <boost/static_assert.hpp>
 #include <iostream>
 #include <string>
@@ -173,6 +174,19 @@
     }
 #endif
 
+ {
+ BOOST_MPL_ASSERT((
+ boost::is_same<
+ result_of::front<ns::point>::type,
+ boost::fusion::extension::adt_attribute_proxy<ns::point,0,false>
+ >));
+ BOOST_MPL_ASSERT((
+ boost::is_same<
+ result_of::front<ns::point const>::type,
+ boost::fusion::extension::adt_attribute_proxy<ns::point,0,true>
+ >));
+ }
+
     return boost::report_errors();
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk