File indexing completed on 2025-01-18 09:34:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #if !defined(BOOST_FUSION_FUNCTIONAL_INVOCATION_INVOKE_PROCEDURE_HPP_INCLUDED)
0011 #if !defined(BOOST_PP_IS_ITERATING)
0012
0013 #include <boost/preprocessor/cat.hpp>
0014 #include <boost/preprocessor/iteration/iterate.hpp>
0015 #include <boost/preprocessor/arithmetic/dec.hpp>
0016 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
0017 #include <boost/preprocessor/repetition/enum.hpp>
0018 #include <boost/preprocessor/repetition/enum_shifted.hpp>
0019 #include <boost/preprocessor/repetition/enum_params.hpp>
0020 #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
0021
0022 #include <boost/type_traits/remove_reference.hpp>
0023 #include <boost/core/enable_if.hpp>
0024
0025 #include <boost/mpl/front.hpp>
0026
0027 #include <boost/function_types/is_callable_builtin.hpp>
0028 #include <boost/function_types/is_member_function_pointer.hpp>
0029 #include <boost/function_types/parameter_types.hpp>
0030
0031 #include <boost/fusion/support/category_of.hpp>
0032 #include <boost/fusion/sequence/intrinsic/at.hpp>
0033 #include <boost/fusion/sequence/intrinsic/size.hpp>
0034 #include <boost/fusion/sequence/intrinsic/begin.hpp>
0035 #include <boost/fusion/iterator/next.hpp>
0036 #include <boost/fusion/iterator/deref.hpp>
0037 #include <boost/fusion/functional/invocation/limits.hpp>
0038 #include <boost/fusion/functional/invocation/detail/that_ptr.hpp>
0039
0040 namespace boost { namespace fusion
0041 {
0042 namespace detail
0043 {
0044 namespace ft = function_types;
0045
0046 template<
0047 typename Function, class Sequence,
0048 int N = result_of::size<Sequence>::value,
0049 bool MFP = ft::is_member_function_pointer<Function>::value,
0050 bool RandomAccess = traits::is_random_access<Sequence>::value
0051 >
0052 struct invoke_procedure_impl;
0053
0054 #define BOOST_PP_FILENAME_1 \
0055 <boost/fusion/functional/invocation/invoke_procedure.hpp>
0056 #define BOOST_PP_ITERATION_LIMITS \
0057 (0, BOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY)
0058 #include BOOST_PP_ITERATE()
0059
0060 }
0061
0062 namespace result_of
0063 {
0064 template <typename Function, class Sequence, class Enable = void>
0065 struct invoke_procedure;
0066
0067 template <typename Function, class Sequence>
0068 struct invoke_procedure<Function, Sequence,
0069 typename enable_if_has_type<
0070 typename detail::invoke_procedure_impl<
0071 typename boost::remove_reference<Function>::type,Sequence
0072 >::result_type
0073 >::type>
0074 {
0075 typedef void type;
0076 };
0077 }
0078
0079 template <typename Function, class Sequence>
0080 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0081 inline typename result_of::invoke_procedure<Function, Sequence>::type
0082 invoke_procedure(Function f, Sequence & s)
0083 {
0084 detail::invoke_procedure_impl<
0085 typename boost::remove_reference<Function>::type,Sequence
0086 >::call(f,s);
0087 }
0088
0089 template <typename Function, class Sequence>
0090 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0091 inline typename result_of::invoke_procedure<Function, Sequence const>::type
0092 invoke_procedure(Function f, Sequence const & s)
0093 {
0094 detail::invoke_procedure_impl<
0095 typename boost::remove_reference<Function>::type,Sequence const
0096 >::call(f,s);
0097 }
0098
0099 }}
0100
0101 #define BOOST_FUSION_FUNCTIONAL_INVOCATION_INVOKE_PROCEDURE_HPP_INCLUDED
0102 #else
0103
0104
0105
0106
0107
0108 #define N BOOST_PP_ITERATION()
0109
0110 #define M(z,j,data) fusion::at_c<j>(s)
0111
0112 template <typename Function, class Sequence>
0113 struct invoke_procedure_impl<Function,Sequence,N,false,true>
0114 {
0115 typedef void result_type;
0116
0117 #if N > 0
0118
0119 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0120 static inline void call(Function & f, Sequence & s)
0121 {
0122 f(BOOST_PP_ENUM(N,M,~));
0123 }
0124
0125 #else
0126
0127 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0128 static inline void call(Function & f, Sequence & )
0129 {
0130 f();
0131 }
0132
0133 #endif
0134
0135 };
0136
0137 #if N > 0
0138 template <typename Function, class Sequence>
0139 struct invoke_procedure_impl<Function,Sequence,N,true,true>
0140 {
0141 typedef void result_type;
0142
0143 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0144 static inline void call(Function & f, Sequence & s)
0145 {
0146 (that_ptr<typename mpl::front<
0147 ft::parameter_types<Function> >::type
0148 >::get(fusion::at_c<0>(s))->*f)(BOOST_PP_ENUM_SHIFTED(N,M,~));
0149 }
0150 };
0151 #endif
0152
0153 #undef M
0154
0155 #define M(z,j,data) \
0156 typedef typename result_of::next< BOOST_PP_CAT(I,BOOST_PP_DEC(j)) \
0157 >::type I ## j ; \
0158 I##j i##j = fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(j)));
0159
0160 template <typename Function, class Sequence>
0161 struct invoke_procedure_impl<Function,Sequence,N,false,false>
0162 {
0163 typedef void result_type;
0164
0165 #if N > 0
0166
0167 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0168 static inline void call(Function & f, Sequence & s)
0169 {
0170 typedef typename result_of::begin<Sequence>::type I0;
0171 I0 i0 = fusion::begin(s);
0172 BOOST_PP_REPEAT_FROM_TO(1,N,M,~)
0173 f( BOOST_PP_ENUM_PARAMS(N,*i) );
0174 }
0175
0176 #else
0177 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0178 static inline void call(Function & f, Sequence & )
0179 {
0180 f();
0181 }
0182
0183 #endif
0184
0185 };
0186
0187 #if N > 0
0188 template <typename Function, class Sequence>
0189 struct invoke_procedure_impl<Function,Sequence,N,true,false>
0190 {
0191 typedef void result_type;
0192
0193 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0194 static inline void call(Function & f, Sequence & s)
0195 {
0196 typedef typename result_of::begin<Sequence>::type I0;
0197 I0 i0 = fusion::begin(s);
0198 BOOST_PP_REPEAT_FROM_TO(1,N,M,~)
0199
0200 (that_ptr<typename mpl::front<
0201 ft::parameter_types<Function> >::type
0202 >::get(*i0)->*f)(BOOST_PP_ENUM_SHIFTED_PARAMS(N,*i));
0203 }
0204 };
0205 #endif
0206
0207 #undef M
0208
0209 #undef N
0210 #endif
0211 #endif
0212