3#include <boost/preprocessor/repeat.hpp>
4#include <boost/preprocessor/repeat_from_to.hpp>
5#include <boost/preprocessor/repetition/enum_binary_params.hpp>
6#include <boost/preprocessor/repetition/enum_params.hpp>
7#include <boost/preprocessor/repetition/enum.hpp>
8#include <boost/preprocessor/facilities/empty.hpp>
9#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
55 template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(9,
typename A,
void)>
struct tuple{};
63 template<
typename Functor>
75 #define RREF_PARAMS(z,n,data) BOOST_PP_CAT(AA,n)&& BOOST_PP_CAT(p,n)
76 #define ILIST_PARAMS(z,n,data) BOOST_PP_CAT(a,n)( fc::forward<BOOST_PP_CAT(AA,n)>( BOOST_PP_CAT(p,n) ) )
77 #define ILIST_PARAMS_COPY(z,n,data) BOOST_PP_CAT(a,n)( t.BOOST_PP_CAT(a,n) )
78 #define VISIT_PARAMS(z,n,data) v(BOOST_PP_CAT(a,n));
79 #define LIST_MEMBERS_ON(z,n,data) data.BOOST_PP_CAT(a,n)
80 #define DEDUCE_MEMBERS(z,n,data) typename fc::deduce<BOOST_PP_CAT(AA,n)>::type
81 #define FORWARD_PARAMS(z,n,data) fc::forward<BOOST_PP_CAT(AA,n)>(BOOST_PP_CAT(p,n))
82 #define MEM_PARAMS(z,n,data) BOOST_PP_CAT(A,n) BOOST_PP_CAT(a,n);
83 #define TUPLE(z,n,unused) \
84 template<BOOST_PP_ENUM_PARAMS( n, typename A)> \
85 struct tuple<BOOST_PP_ENUM_PARAMS(n,A)> { \
86 enum size_enum { size = n }; \
87 template<BOOST_PP_ENUM_PARAMS( n, typename AA)> \
88 explicit tuple( BOOST_PP_ENUM(n, RREF_PARAMS, unused ) )BOOST_PP_IF(n,:,BOOST_PP_EMPTY())BOOST_PP_ENUM( n, ILIST_PARAMS,unused){} \
89 tuple( const tuple& t )BOOST_PP_IF(n,:,BOOST_PP_EMPTY())BOOST_PP_ENUM( n, ILIST_PARAMS_COPY,unused){} \
90 tuple( tuple&& t )BOOST_PP_IF(n,:,BOOST_PP_EMPTY())BOOST_PP_ENUM( n, ILIST_PARAMS_COPY,unused){} \
93 void visit( V&& v ) { BOOST_PP_REPEAT(n,VISIT_PARAMS,a) }\
95 void visit( V&& v )const { BOOST_PP_REPEAT(n,VISIT_PARAMS,a) }\
96 BOOST_PP_REPEAT(n,MEM_PARAMS,a) \
98 template<BOOST_PP_ENUM_PARAMS( n, typename AA)> \
99 tuple<BOOST_PP_ENUM_PARAMS(n,AA)> make_tuple( BOOST_PP_ENUM( n, RREF_PARAMS, unused) ) { \
100 return tuple<BOOST_PP_ENUM_PARAMS(n,AA)>( BOOST_PP_ENUM( n, FORWARD_PARAMS,unused ) ); \
102 template<typename Functor, BOOST_PP_ENUM_PARAMS(n,typename AA)> \
103 auto call_fused( Functor f, tuple<BOOST_PP_ENUM_PARAMS(n,AA)>& t ) \
104 -> decltype( f( BOOST_PP_ENUM( n, LIST_MEMBERS_ON, t) ) ) { \
105 return f( BOOST_PP_ENUM( n, LIST_MEMBERS_ON, t) ); \
107 template<typename Functor, BOOST_PP_ENUM_PARAMS(n,typename AA)> \
108 auto call_fused( Functor f, const tuple<BOOST_PP_ENUM_PARAMS(n,AA)>& t ) \
109 -> decltype( f( BOOST_PP_ENUM( n, LIST_MEMBERS_ON, t) ) ) { \
110 return f( BOOST_PP_ENUM( n, LIST_MEMBERS_ON, t) ); \
112 template<BOOST_PP_ENUM_PARAMS( n, typename AA)> \
113 struct is_tuple<fc::tuple<BOOST_PP_ENUM_PARAMS(n,AA)> > { \
114 typedef fc::true_type type; \
116 template<BOOST_PP_ENUM_PARAMS( n, typename AA)> \
117 struct deduce<fc::tuple<BOOST_PP_ENUM_PARAMS(n,AA)> > { \
118 typedef fc::tuple<BOOST_PP_ENUM( n, DEDUCE_MEMBERS,unused)> type; \
121 BOOST_PP_REPEAT_FROM_TO( 1, 5,
TUPLE, unused )
124 #undef FORWARD_PARAMS
125 #undef DEDUCE_MEMBERS
127 #undef LIST_MEMBERS_ON
129 #undef ILIST_PARAMS_COPY
auto call_fused(Functor f, const tuple<> &t) -> decltype(f())
#define TUPLE(z, n, unused)