diff --git a/include/boost/fusion/adapted/adt/detail/adapt_base.hpp b/include/boost/fusion/adapted/adt/detail/adapt_base.hpp index ac618cb6..0a21aa1f 100644 --- a/include/boost/fusion/adapted/adt/detail/adapt_base.hpp +++ b/include/boost/fusion/adapted/adt/detail/adapt_base.hpp @@ -33,7 +33,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 \ + static void \ + boost_fusion_adapt_adt_impl_set( \ + BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj, \ + Arg const& 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 +75,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,7 +102,8 @@ 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) \ {} \ \ @@ -78,19 +111,22 @@ adt_attribute_proxy& \ operator=(Arg const& 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, 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< \ @@ -117,7 +153,7 @@ struct apply \ { \ typedef \ - access::adt_attribute_proxy< \ + adt_attribute_proxy< \ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \ , I \ , is_const::value \ @@ -127,7 +163,7 @@ static type \ call(Seq& obj) \ { \ - return type(obj); \ + return type(&obj); \ } \ }; \ }; diff --git a/include/boost/fusion/adapted/struct/detail/extension.hpp b/include/boost/fusion/adapted/struct/detail/extension.hpp index 6d715753..17edb89d 100644 --- a/include/boost/fusion/adapted/struct/detail/extension.hpp +++ b/include/boost/fusion/adapted/struct/detail/extension.hpp @@ -32,10 +32,13 @@ namespace boost { namespace fusion template struct struct_member; - template - struct adt_attribute_proxy; + template + struct adt_attribute_access; }; + template + struct adt_attribute_proxy; + template struct struct_member_name; diff --git a/test/sequence/adapt_adt.cpp b/test/sequence/adapt_adt.cpp index bfbd5fac..e0693568 100644 --- a/test/sequence/adapt_adt.cpp +++ b/test/sequence/adapt_adt.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -174,6 +175,29 @@ main() } #endif + { + BOOST_MPL_ASSERT(( + boost::is_same< + result_of::front::type, + boost::fusion::extension::adt_attribute_proxy + >)); + BOOST_MPL_ASSERT(( + boost::is_same< + result_of::front::type::type, + int + >)); + BOOST_MPL_ASSERT(( + boost::is_same< + result_of::front::type, + boost::fusion::extension::adt_attribute_proxy + >)); + BOOST_MPL_ASSERT(( + boost::is_same< + result_of::front::type::type, + int + >)); + } + return boost::report_errors(); }