summaryrefslogtreecommitdiff
path: root/boost/fusion/adapted/adt/detail/adapt_base.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/fusion/adapted/adt/detail/adapt_base.hpp')
-rw-r--r--boost/fusion/adapted/adt/detail/adapt_base.hpp128
1 files changed, 114 insertions, 14 deletions
diff --git a/boost/fusion/adapted/adt/detail/adapt_base.hpp b/boost/fusion/adapted/adt/detail/adapt_base.hpp
index 3de396d..dec1725 100644
--- a/boost/fusion/adapted/adt/detail/adapt_base.hpp
+++ b/boost/fusion/adapted/adt/detail/adapt_base.hpp
@@ -11,11 +11,18 @@
#define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_HPP
#include <boost/fusion/support/config.hpp>
+#include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
+#include <boost/fusion/adapted/struct/detail/adapt_is_tpl.hpp>
+
#include <boost/preprocessor/control/if.hpp>
#include <boost/preprocessor/seq/seq.hpp>
#include <boost/preprocessor/seq/elem.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/typeof/typeof.hpp>
#define BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_TEMPLATE_IMPL(TEMPLATE_PARAMS_SEQ) \
typename detail::get_identity< \
@@ -28,8 +35,72 @@
\
boost::remove_const<boost::remove_reference<lvalue>::type>::type
+#define BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \
+ ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE) \
+ BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, \
+ BOOST_PP_IF(DEDUCE_TYPE, 0, 2), ATTRIBUTE)
+
+#define BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_SETEXPR(ATTRIBUTE, \
+ ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE) \
+ BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, \
+ BOOST_PP_IF(DEDUCE_TYPE, 1, 3), ATTRIBUTE)
+
+#ifdef BOOST_MSVC
+# define BOOST_FUSION_DEDUCED_ATTR_TYPE(NAME_SEQ, ATTRIBUTE, \
+ ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
+ \
+ BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \
+ TEMPLATE_PARAMS_SEQ) \
+ \
+ struct deduced_attr_type { \
+ static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \
+ typedef \
+ BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \
+ BOOST_TYPEOF( PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR( \
+ ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, 1)) type; \
+ };
+
+#else
+# define BOOST_FUSION_DEDUCED_ATTR_TYPE(NAME_SEQ, ATTRIBUTE, \
+ ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
+ struct deduced_attr_type { \
+ static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \
+ typedef BOOST_TYPEOF( PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR( \
+ ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, 1)) type; \
+ };
+
+#endif
+
+#define BOOST_FUSION_ADT_ATTRIBUTE_TYPEOF( \
+ NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
+ \
+ BOOST_FUSION_DEDUCED_ATTR_TYPE( \
+ NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
+ \
+ typedef \
+ BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \
+ boost::remove_const< \
+ BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \
+ deduced_attr_type::type \
+ >::type type; \
+ \
+ typedef \
+ BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \
+ boost::add_const< \
+ BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ),typename,) \
+ deduced_attr_type::type \
+ >::type const_type;
+
+#define BOOST_FUSION_ADT_ATTRIBUTE_GIVENTYPE( \
+ NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPEL_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
+ \
+ typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \
+ typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) const_type;
+
+
#define BOOST_FUSION_ADAPT_ADT_C_BASE( \
- TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE) \
+ TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,PREFIX, \
+ ATTRIBUTE,ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE) \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
@@ -39,30 +110,43 @@
, I \
> \
{ \
+ \
+ BOOST_PP_IF(DEDUCE_TYPE, \
+ BOOST_FUSION_ADT_ATTRIBUTE_TYPEOF, \
+ BOOST_FUSION_ADT_ATTRIBUTE_GIVENTYPE)( \
+ NAME_SEQ, \
+ ATTRIBUTE, \
+ ATTRIBUTE_TUPEL_SIZE, \
+ PREFIX, \
+ TEMPLATE_PARAMS_SEQ) \
+ \
template<class Val> \
- BOOST_FUSION_GPU_ENABLED \
+ BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
static void \
boost_fusion_adapt_adt_impl_set( \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj, \
Val const& val) \
{ \
- BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 3, ATTRIBUTE); \
+ PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_SETEXPR(ATTRIBUTE, \
+ ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE); \
} \
\
BOOST_FUSION_GPU_ENABLED \
- static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) \
+ static type \
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); \
+ return PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \
+ ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE); \
} \
\
BOOST_FUSION_GPU_ENABLED \
- static BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) \
+ static const_type \
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); \
+ return PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \
+ ATTRIBUTE_TUPEL_SIZE, DEDUCE_TYPE); \
} \
}; \
\
@@ -75,9 +159,14 @@
, true \
> \
{ \
- typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 1, ATTRIBUTE) type; \
+ typedef \
+ BOOST_PP_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), typename, ) \
+ access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ >::const_type type; \
\
- BOOST_FUSION_GPU_ENABLED \
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
explicit \
adt_attribute_proxy( \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& o) \
@@ -111,9 +200,14 @@
, false \
> \
{ \
- typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) type; \
+ typedef \
+ BOOST_PP_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), typename, ) \
+ access::adt_attribute_access< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ >::type type; \
\
- BOOST_FUSION_GPU_ENABLED \
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
explicit \
adt_attribute_proxy( \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& o) \
@@ -121,7 +215,7 @@
{} \
\
template<class Val> \
- BOOST_FUSION_GPU_ENABLED \
+ BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
adt_attribute_proxy& \
operator=(Val const& val) \
{ \
@@ -158,7 +252,13 @@
, I \
> \
{ \
- typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE, 0, ATTRIBUTE) lvalue; \
+ typedef BOOST_PP_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), typename, ) \
+ adt_attribute_proxy< \
+ BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
+ , I \
+ , false \
+ >::type lvalue; \
+ \
BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \
TEMPLATE_PARAMS_SEQ) \
\
@@ -181,7 +281,7 @@
> \
type; \
\
- BOOST_FUSION_GPU_ENABLED \
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
static type \
call(Seq& obj) \
{ \