From 78ff3d883114d0422db0f782188be1ff250bf63d Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Tue, 4 Sep 2012 13:40:38 +0000 Subject: [PATCH] Fixed code to allow decltype implementation of boost::result_of with BOOST_RESULT_OF_USE_DECLTYPE defined. [SVN r80395] --- .../fusion/functional/invocation/invoke.hpp | 81 +++++++++++++++++-- 1 file changed, 73 insertions(+), 8 deletions(-) diff --git a/include/boost/fusion/functional/invocation/invoke.hpp b/include/boost/fusion/functional/invocation/invoke.hpp index 085beb7e..1a491702 100644 --- a/include/boost/fusion/functional/invocation/invoke.hpp +++ b/include/boost/fusion/functional/invocation/invoke.hpp @@ -57,13 +57,13 @@ namespace boost { namespace fusion template struct invoke; } - template - inline typename result_of::invoke::type - invoke(Function, Sequence &); + //~ template + //~ inline typename result_of::invoke::type + //~ invoke(Function, Sequence &); - template - inline typename result_of::invoke::type - invoke(Function, Sequence const &); + //~ template + //~ inline typename result_of::invoke::type + //~ invoke(Function, Sequence const &); //----- ---- --- -- - - - - @@ -85,6 +85,9 @@ namespace boost { namespace fusion template struct invoke_data_member; + template + struct invoke_fn_ptr; + template struct invoke_mem_fn; @@ -95,10 +98,10 @@ namespace boost { namespace fusion template struct invoke_nonmember_builtin // use same implementation as for function objects but... - : invoke_impl< // ...work around boost::result_of bugs + : invoke_fn_ptr< // ...work around boost::result_of bugs typename mpl::eval_if< ft::is_function, boost::add_reference, boost::remove_cv >::type, - Sequence, N, false, RandomAccess > + Sequence, N, RandomAccess > { }; template @@ -199,6 +202,35 @@ namespace boost { namespace fusion Function(BOOST_PP_ENUM(N,M,~)) >::type result_type; #undef M +#if N > 0 + + template + static inline result_type + call(F & f, Sequence & s) + { +#define M(z,j,data) fusion::at_c(s) + return f( BOOST_PP_ENUM(N,M,~) ); + } + +#else + template + static inline result_type + call(F & f, Sequence & /*s*/) + { + return f(); + } + +#endif + + }; + + template + struct invoke_fn_ptr + { + public: + + typedef typename ft::result_type::type result_type; + #if N > 0 template @@ -278,6 +310,39 @@ namespace boost { namespace fusion return f(); } +#endif + + }; + + template + struct invoke_fn_ptr + { + private: + typedef invoke_param_types seq; + public: + + typedef typename ft::result_type::type result_type; + +#if N > 0 + + template + static inline result_type + call(F & f, Sequence & s) + { + typename seq::I0 i0 = fusion::begin(s); + BOOST_PP_REPEAT_FROM_TO(1,N,M,~) + return f( BOOST_PP_ENUM_PARAMS(N,*i) ); + } + +#else + + template + static inline result_type + call(F & f, Sequence & /*s*/) + { + return f(); + } + #endif };