mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-30 20:47:31 +02:00
adds const-correctness, simplification
[SVN r38201]
This commit is contained in:
@ -79,7 +79,7 @@ namespace boost { namespace fusion
|
|||||||
template <class Function, class Sequence> struct invoke_function_object
|
template <class Function, class Sequence> struct invoke_function_object
|
||||||
: detail::invoke_function_object_impl<
|
: detail::invoke_function_object_impl<
|
||||||
typename boost::remove_reference<Function>::type, Sequence
|
typename boost::remove_reference<Function>::type, Sequence
|
||||||
>::template result<>
|
>::result
|
||||||
{ };
|
{ };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,18 +117,16 @@ namespace boost { namespace fusion
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template <typename _ = void>
|
|
||||||
struct result
|
struct result
|
||||||
#define M(z,j,data) \
|
#define M(z,j,data) \
|
||||||
typename boost::remove_reference< \
|
typename boost::remove_reference< \
|
||||||
typename result_of::value_at_c<Sequence,j>::type >::type
|
typename result_of::value_at_c<Sequence,j>::type >::type
|
||||||
: boost::result_of<
|
: boost::result_of< Function (BOOST_PP_ENUM(N,M,~)) >
|
||||||
typename remove_const<Function>::type (BOOST_PP_ENUM(N,M,~))>
|
|
||||||
#undef M
|
#undef M
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
static inline typename result<F>::type
|
static inline typename result::type
|
||||||
call(F & f, Sequence & s)
|
call(F & f, Sequence & s)
|
||||||
{
|
{
|
||||||
#define M(z,j,data) fusion::at_c<j>(s)
|
#define M(z,j,data) fusion::at_c<j>(s)
|
||||||
@ -143,17 +141,13 @@ namespace boost { namespace fusion
|
|||||||
private:
|
private:
|
||||||
typedef invoke_function_object_param_types<Sequence,N> seq;
|
typedef invoke_function_object_param_types<Sequence,N> seq;
|
||||||
public:
|
public:
|
||||||
template <typename _ = void>
|
|
||||||
struct result
|
struct result
|
||||||
|
: boost::result_of<
|
||||||
{
|
Function (BOOST_PP_ENUM_PARAMS(N,typename seq::T)) >
|
||||||
typedef typename
|
{ };
|
||||||
boost::result_of<
|
|
||||||
typename remove_const<Function>::type (BOOST_PP_ENUM_PARAMS(N,typename seq::T))>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
static inline typename result<F>::type
|
static inline typename result::type
|
||||||
call(F & f, Sequence & s)
|
call(F & f, Sequence & s)
|
||||||
{
|
{
|
||||||
#if N > 0
|
#if N > 0
|
||||||
|
@ -19,24 +19,13 @@
|
|||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
||||||
|
|
||||||
#include <boost/mpl/if.hpp>
|
|
||||||
#include <boost/mpl/or.hpp>
|
|
||||||
#include <boost/mpl/and.hpp>
|
|
||||||
#include <boost/mpl/less.hpp>
|
|
||||||
#include <boost/mpl/equal_to.hpp>
|
|
||||||
#include <boost/mpl/bool.hpp>
|
|
||||||
#include <boost/mpl/size_t.hpp>
|
|
||||||
#include <boost/mpl/front.hpp>
|
|
||||||
#include <boost/mpl/identity.hpp>
|
|
||||||
|
|
||||||
#include <boost/blank.hpp>
|
|
||||||
|
|
||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
|
|
||||||
|
#include <boost/mpl/front.hpp>
|
||||||
|
|
||||||
#include <boost/function_types/is_callable_builtin.hpp>
|
#include <boost/function_types/is_callable_builtin.hpp>
|
||||||
#include <boost/function_types/is_member_function_pointer.hpp>
|
#include <boost/function_types/is_member_function_pointer.hpp>
|
||||||
#include <boost/function_types/parameter_types.hpp>
|
#include <boost/function_types/parameter_types.hpp>
|
||||||
#include <boost/function_types/function_arity.hpp>
|
|
||||||
|
|
||||||
#include <boost/fusion/support/category_of.hpp>
|
#include <boost/fusion/support/category_of.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||||
@ -51,7 +40,10 @@ namespace boost { namespace fusion
|
|||||||
{
|
{
|
||||||
namespace result_of
|
namespace result_of
|
||||||
{
|
{
|
||||||
template <typename Function, class Sequence> struct invoke_procedure;
|
template <typename Function, class Sequence> struct invoke_procedure
|
||||||
|
{
|
||||||
|
typedef void type;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Function, class Sequence>
|
template <typename Function, class Sequence>
|
||||||
@ -69,27 +61,10 @@ namespace boost { namespace fusion
|
|||||||
template<
|
template<
|
||||||
typename Function, class Sequence,
|
typename Function, class Sequence,
|
||||||
int N = result_of::size<Sequence>::value,
|
int N = result_of::size<Sequence>::value,
|
||||||
bool CBI = ft::is_callable_builtin<Function>::value,
|
|
||||||
bool MFP = ft::is_member_function_pointer<Function>::value,
|
bool MFP = ft::is_member_function_pointer<Function>::value,
|
||||||
bool RandomAccess = traits::is_random_access<Sequence>::value
|
bool RandomAccess = traits::is_random_access<Sequence>::value
|
||||||
>
|
>
|
||||||
struct invoke_procedure_impl
|
struct invoke_procedure_impl;
|
||||||
{
|
|
||||||
typedef boost::blank result;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Func, class N, bool CBI = true>
|
|
||||||
// Contains void type member, empty on arity mismatch
|
|
||||||
struct invoke_procedure_result
|
|
||||||
: mpl::if_<
|
|
||||||
mpl::or_<
|
|
||||||
mpl::bool_<! CBI>,
|
|
||||||
mpl::equal_to< ft::function_arity<Func>, N >,
|
|
||||||
mpl::and_< ft::is_callable_builtin<Func, ft::variadic>,
|
|
||||||
mpl::less< ft::function_arity<Func>, N > >
|
|
||||||
>, mpl::identity<void>, boost::blank
|
|
||||||
>::type
|
|
||||||
{ };
|
|
||||||
|
|
||||||
#define BOOST_PP_FILENAME_1 \
|
#define BOOST_PP_FILENAME_1 \
|
||||||
<boost/fusion/functional/invocation/invoke_procedure.hpp>
|
<boost/fusion/functional/invocation/invoke_procedure.hpp>
|
||||||
@ -99,15 +74,6 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace result_of
|
|
||||||
{
|
|
||||||
template <typename Function, class Sequence> struct invoke_procedure
|
|
||||||
: detail::invoke_procedure_impl<
|
|
||||||
typename boost::remove_reference<Function>::type, Sequence
|
|
||||||
>::result
|
|
||||||
{ };
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Function, class Sequence>
|
template <typename Function, class Sequence>
|
||||||
inline void invoke_procedure(Function f, Sequence & s)
|
inline void invoke_procedure(Function f, Sequence & s)
|
||||||
{
|
{
|
||||||
@ -137,13 +103,9 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
#define M(z,j,data) fusion::at_c<j>(s)
|
#define M(z,j,data) fusion::at_c<j>(s)
|
||||||
|
|
||||||
template <typename Function, class Sequence, bool CBI>
|
template <typename Function, class Sequence>
|
||||||
struct invoke_procedure_impl<Function,Sequence,N,CBI,false,true>
|
struct invoke_procedure_impl<Function,Sequence,N,false,true>
|
||||||
{
|
{
|
||||||
struct result
|
|
||||||
: invoke_procedure_result< Function, mpl::size_t<N>, CBI >
|
|
||||||
{ };
|
|
||||||
|
|
||||||
static inline void call(Function & f, Sequence & s)
|
static inline void call(Function & f, Sequence & s)
|
||||||
{
|
{
|
||||||
f(BOOST_PP_ENUM(N,M,~));
|
f(BOOST_PP_ENUM(N,M,~));
|
||||||
@ -152,12 +114,8 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
#if N > 0
|
#if N > 0
|
||||||
template <typename Function, class Sequence>
|
template <typename Function, class Sequence>
|
||||||
struct invoke_procedure_impl<Function,Sequence,N,true,true,true>
|
struct invoke_procedure_impl<Function,Sequence,N,true,true>
|
||||||
{
|
{
|
||||||
struct result
|
|
||||||
: invoke_procedure_result< Function, mpl::size_t<N> >
|
|
||||||
{ };
|
|
||||||
|
|
||||||
static inline void call(Function & f, Sequence & s)
|
static inline void call(Function & f, Sequence & s)
|
||||||
{
|
{
|
||||||
(that_ptr<typename mpl::front<
|
(that_ptr<typename mpl::front<
|
||||||
@ -174,13 +132,9 @@ namespace boost { namespace fusion
|
|||||||
>::type I ## j ; \
|
>::type I ## j ; \
|
||||||
I##j i##j = fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(j)));
|
I##j i##j = fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(j)));
|
||||||
|
|
||||||
template <typename Function, class Sequence, bool CBI>
|
template <typename Function, class Sequence>
|
||||||
struct invoke_procedure_impl<Function,Sequence,N,CBI,false,false>
|
struct invoke_procedure_impl<Function,Sequence,N,false,false>
|
||||||
{
|
{
|
||||||
struct result
|
|
||||||
: invoke_procedure_result< Function, mpl::size_t<N>, CBI >
|
|
||||||
{ };
|
|
||||||
|
|
||||||
static inline void call(Function & f, Sequence & s)
|
static inline void call(Function & f, Sequence & s)
|
||||||
{
|
{
|
||||||
#if N > 0
|
#if N > 0
|
||||||
@ -194,12 +148,8 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
#if N > 0
|
#if N > 0
|
||||||
template <typename Function, class Sequence>
|
template <typename Function, class Sequence>
|
||||||
struct invoke_procedure_impl<Function,Sequence,N,true,true,false>
|
struct invoke_procedure_impl<Function,Sequence,N,true,false>
|
||||||
{
|
{
|
||||||
struct result
|
|
||||||
: invoke_procedure_result< Function, mpl::size_t<N> >
|
|
||||||
{ };
|
|
||||||
|
|
||||||
static inline void call(Function & f, Sequence & s)
|
static inline void call(Function & f, Sequence & s)
|
||||||
{
|
{
|
||||||
typedef typename result_of::begin<Sequence>::type I0;
|
typedef typename result_of::begin<Sequence>::type I0;
|
||||||
|
Reference in New Issue
Block a user