mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-17 14:22:13 +02:00
Fusion/Spirit: adt_attribute_proxy refactorization
[SVN r65445]
This commit is contained in:
@ -33,7 +33,39 @@
|
|||||||
template< \
|
template< \
|
||||||
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
|
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, \
|
||||||
|
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) \
|
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
|
||||||
, I \
|
, I \
|
||||||
, true \
|
, true \
|
||||||
@ -43,25 +75,25 @@
|
|||||||
\
|
\
|
||||||
explicit \
|
explicit \
|
||||||
adt_attribute_proxy( \
|
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) \
|
: obj(o) \
|
||||||
{} \
|
{} \
|
||||||
\
|
\
|
||||||
operator type() const \
|
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; \
|
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const* obj; \
|
||||||
\
|
|
||||||
private: \
|
|
||||||
adt_attribute_proxy& operator= (adt_attribute_proxy const&); \
|
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template< \
|
template< \
|
||||||
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
|
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) \
|
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
|
||||||
, I \
|
, I \
|
||||||
, false \
|
, false \
|
||||||
@ -70,7 +102,8 @@
|
|||||||
typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \
|
typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \
|
||||||
\
|
\
|
||||||
explicit \
|
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) \
|
: obj(o) \
|
||||||
{} \
|
{} \
|
||||||
\
|
\
|
||||||
@ -78,19 +111,22 @@
|
|||||||
adt_attribute_proxy& \
|
adt_attribute_proxy& \
|
||||||
operator=(Arg const& val) \
|
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; \
|
return *this; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
operator type() const \
|
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; \
|
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)* obj; \
|
||||||
\
|
|
||||||
private: \
|
|
||||||
adt_attribute_proxy& operator= (adt_attribute_proxy const&); \
|
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template< \
|
template< \
|
||||||
@ -117,7 +153,7 @@
|
|||||||
struct apply \
|
struct apply \
|
||||||
{ \
|
{ \
|
||||||
typedef \
|
typedef \
|
||||||
access::adt_attribute_proxy< \
|
adt_attribute_proxy< \
|
||||||
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
|
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
|
||||||
, I \
|
, I \
|
||||||
, is_const<Seq>::value \
|
, is_const<Seq>::value \
|
||||||
@ -127,7 +163,7 @@
|
|||||||
static type \
|
static type \
|
||||||
call(Seq& obj) \
|
call(Seq& obj) \
|
||||||
{ \
|
{ \
|
||||||
return type(obj); \
|
return type(&obj); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
};
|
};
|
||||||
|
@ -32,9 +32,12 @@ namespace boost { namespace fusion
|
|||||||
template<typename Seq, int N>
|
template<typename Seq, int N>
|
||||||
struct struct_member;
|
struct struct_member;
|
||||||
|
|
||||||
|
template<typename Seq, int N>
|
||||||
|
struct adt_attribute_access;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, int N, bool Const>
|
template <typename T, int N, bool Const>
|
||||||
struct adt_attribute_proxy;
|
struct adt_attribute_proxy;
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Seq, int N>
|
template<typename Seq, int N>
|
||||||
struct struct_member_name;
|
struct struct_member_name;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <boost/mpl/front.hpp>
|
#include <boost/mpl/front.hpp>
|
||||||
#include <boost/mpl/is_sequence.hpp>
|
#include <boost/mpl/is_sequence.hpp>
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/mpl/assert.hpp>
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -174,6 +175,29 @@ main()
|
|||||||
}
|
}
|
||||||
#endif
|
#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>::type::type,
|
||||||
|
int
|
||||||
|
>));
|
||||||
|
BOOST_MPL_ASSERT((
|
||||||
|
boost::is_same<
|
||||||
|
result_of::front<ns::point const>::type,
|
||||||
|
boost::fusion::extension::adt_attribute_proxy<ns::point,0,true>
|
||||||
|
>));
|
||||||
|
BOOST_MPL_ASSERT((
|
||||||
|
boost::is_same<
|
||||||
|
result_of::front<ns::point const>::type::type,
|
||||||
|
int
|
||||||
|
>));
|
||||||
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user