forked from boostorg/fusion
completes boost::result_of-based result type computation
[SVN r38194]
This commit is contained in:
@ -26,43 +26,101 @@ namespace boost { namespace fusion { namespace detail
|
||||
template<typename Function>
|
||||
struct get_result_spec
|
||||
{
|
||||
typedef typename remove_const<typename remove_reference<Function>::type>::type function;
|
||||
typedef typename function::template result<function(fusion::vector0)> type;
|
||||
private:
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_reference<Function>::type>::type function;
|
||||
|
||||
typedef fusion::vector0 arg;
|
||||
public:
|
||||
typedef typename function::template result<function(arg)> call_0_result;
|
||||
typedef typename function::template result<function const (arg)>
|
||||
call_const_0_result;
|
||||
};
|
||||
|
||||
template <class Derived, class Function, bool Enable = detail::has_type<
|
||||
typename get_result_spec<Function>::type>::value>
|
||||
template <class Derived, class Function,
|
||||
bool EnableConst = detail::has_type<
|
||||
typename get_result_spec<Function>::call_const_0_result>::value,
|
||||
bool Enable = detail::has_type<
|
||||
typename get_result_spec<Function>::call_0_result>::value>
|
||||
struct nullary_call_base
|
||||
{
|
||||
template <typename T> inline void operator()(T reserved::*) const { }
|
||||
protected:
|
||||
typedef boost::blank r0;
|
||||
};
|
||||
typedef typename get_result_spec<Function>::call_const_0_result
|
||||
call_const_0_result_class;
|
||||
|
||||
template <class Derived, class Function>
|
||||
struct nullary_call_base<Derived,Function,true>
|
||||
{
|
||||
private:
|
||||
typedef typename remove_const<typename remove_reference<Function>::type>::type function;
|
||||
protected:
|
||||
typedef typename function::template result<function(vector0)> r0;
|
||||
typedef typename get_result_spec<Function>::call_0_result
|
||||
call_0_result_class;
|
||||
public:
|
||||
typedef typename call_const_0_result_class::type
|
||||
call_const_0_result;
|
||||
|
||||
inline typename r0::type
|
||||
operator()() const
|
||||
inline call_const_0_result operator()() const
|
||||
{
|
||||
fusion::vector0 arg;
|
||||
return static_cast<Derived const *>(this)->fnc_transformed(arg);
|
||||
}
|
||||
|
||||
inline typename r0::type
|
||||
operator()()
|
||||
typedef typename get_result_spec<Function>::call_0_result::type
|
||||
call_0_result;
|
||||
|
||||
inline call_0_result operator()()
|
||||
{
|
||||
fusion::vector0 arg;
|
||||
return static_cast<Derived *>(this)->fnc_transformed(arg);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Derived, class Function>
|
||||
struct nullary_call_base<Derived, Function, true, false>
|
||||
{
|
||||
protected:
|
||||
typedef typename get_result_spec<Function>::call_const_0_result
|
||||
call_const_0_result_class;
|
||||
|
||||
typedef typename boost::blank call_0_result_class;
|
||||
public:
|
||||
typedef typename call_const_0_result_class::type
|
||||
call_const_0_result, call_0_result;
|
||||
|
||||
inline call_const_0_result operator()() const
|
||||
{
|
||||
fusion::vector0 arg;
|
||||
return static_cast<Derived const *>(this)->fnc_transformed(arg);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Derived, class Function>
|
||||
struct nullary_call_base<Derived, Function, false, true>
|
||||
{
|
||||
protected:
|
||||
typedef typename boost::blank call_const_0_result_class;
|
||||
|
||||
typedef typename get_result_spec<Function>::call_0_result
|
||||
call_0_result_class;
|
||||
public:
|
||||
typedef void call_const_0_result;
|
||||
typedef typename call_0_result_class::type call_0_result;
|
||||
|
||||
inline call_const_0_result operator()()
|
||||
{
|
||||
fusion::vector0 arg;
|
||||
return static_cast<Derived *>(this)->fnc_transformed(arg);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Derived, class Function>
|
||||
struct nullary_call_base<Derived, Function, false, false>
|
||||
{
|
||||
protected:
|
||||
typedef boost::blank call_0_result_class;
|
||||
typedef boost::blank call_const_0_result_class;
|
||||
public:
|
||||
typedef void call_0_result;
|
||||
typedef void call_const_0_result;
|
||||
|
||||
template <typename T> inline void operator()(T reserved::*) const { }
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
@ -35,40 +35,47 @@ namespace boost { namespace fusion
|
||||
{ }
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke<Function,Seq const>::type
|
||||
inline typename result_of::invoke<func_const_fwd_t,Seq const>::type
|
||||
operator()(Seq const & s) const
|
||||
{
|
||||
return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke<Function,Seq const>::type
|
||||
inline typename result_of::invoke<func_fwd_t,Seq const>::type
|
||||
operator()(Seq const & s)
|
||||
{
|
||||
return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke<Function,Seq>::type
|
||||
inline typename result_of::invoke<func_const_fwd_t,Seq>::type
|
||||
operator()(Seq & s) const
|
||||
{
|
||||
return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke<Function,Seq>::type
|
||||
inline typename result_of::invoke<func_fwd_t,Seq>::type
|
||||
operator()(Seq & s)
|
||||
{
|
||||
return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct result;
|
||||
|
||||
template <typename Func, class Seq>
|
||||
struct result<fused<Func>(Seq)>
|
||||
: result_of::invoke<Function,Seq>
|
||||
template <typename Sig>
|
||||
struct result
|
||||
{ };
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self const (Seq) >
|
||||
: result_of::invoke<func_const_fwd_t,Seq>
|
||||
{ };
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: result_of::invoke<func_fwd_t,Seq>
|
||||
{ };
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
@ -35,16 +35,16 @@ namespace boost { namespace fusion
|
||||
{ }
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke_function_object<Function,Seq const
|
||||
>::type operator()(Seq const & s) const
|
||||
inline typename result_of::invoke_function_object<func_const_fwd_t,
|
||||
Seq const>::type operator()(Seq const & s) const
|
||||
{
|
||||
return fusion::invoke_function_object<
|
||||
func_const_fwd_t >(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke_function_object<Function,Seq const
|
||||
>::type
|
||||
inline typename result_of::invoke_function_object<func_fwd_t,
|
||||
Seq const>::type
|
||||
operator()(Seq const & s)
|
||||
{
|
||||
return fusion::invoke_function_object<
|
||||
@ -52,7 +52,8 @@ namespace boost { namespace fusion
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke_function_object<Function,Seq>::type
|
||||
inline typename result_of::invoke_function_object<func_const_fwd_t,
|
||||
Seq>::type
|
||||
operator()(Seq & s) const
|
||||
{
|
||||
return fusion::invoke_function_object<
|
||||
@ -60,7 +61,7 @@ namespace boost { namespace fusion
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke_function_object<Function,Seq>::type
|
||||
inline typename result_of::invoke_function_object<func_fwd_t,Seq>::type
|
||||
operator()(Seq & s)
|
||||
{
|
||||
return fusion::invoke_function_object<
|
||||
@ -68,11 +69,17 @@ namespace boost { namespace fusion
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct result;
|
||||
struct result
|
||||
{ };
|
||||
|
||||
template <typename Seq>
|
||||
struct result<fused_function_object(Seq)>
|
||||
: result_of::invoke_function_object<Function, Seq>
|
||||
template <class Self, class Seq>
|
||||
struct result< Self const (Seq) >
|
||||
: result_of::invoke_function_object<func_const_fwd_t, Seq>
|
||||
{ };
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: result_of::invoke_function_object<func_fwd_t, Seq>
|
||||
{ };
|
||||
};
|
||||
|
||||
|
@ -35,43 +35,42 @@ namespace boost { namespace fusion
|
||||
{ }
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke_procedure<Function,Seq const>::type
|
||||
operator()(Seq const & s) const
|
||||
inline void operator()(Seq const & s) const
|
||||
{
|
||||
return fusion::invoke_procedure<
|
||||
fusion::invoke_procedure<
|
||||
func_const_fwd_t >(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke_procedure<Function,Seq const>::type
|
||||
operator()(Seq const & s)
|
||||
inline void operator()(Seq const & s)
|
||||
{
|
||||
fusion::invoke_procedure<
|
||||
func_fwd_t >(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline void operator()(Seq & s) const
|
||||
{
|
||||
fusion::invoke_procedure<
|
||||
func_const_fwd_t >(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline void operator()(Seq & s)
|
||||
{
|
||||
return fusion::invoke_procedure<
|
||||
func_fwd_t >(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke_procedure<Function,Seq>::type
|
||||
operator()(Seq & s) const
|
||||
{
|
||||
return fusion::invoke_procedure<
|
||||
func_const_fwd_t >(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
inline typename result_of::invoke_procedure<Function,Seq>::type
|
||||
operator()(Seq & s)
|
||||
{
|
||||
return fusion::invoke_procedure<
|
||||
func_fwd_t >(this->fnc_transformed,s);
|
||||
}
|
||||
|
||||
template <class Seq>
|
||||
template <typename Sig>
|
||||
struct result
|
||||
: result_of::invoke_procedure<Function,Seq>
|
||||
{ };
|
||||
|
||||
typedef void result_type;
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
};
|
||||
}}
|
||||
|
||||
|
@ -31,6 +31,9 @@
|
||||
# elif BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE
|
||||
# error "BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE"
|
||||
# endif
|
||||
# if !defined(BOOST_FUSION_CONSTRUCTOR_MAX_ARITY)
|
||||
# define BOOST_FUSION_CONSTRUCTOR_MAX_ARITY 6
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -56,17 +56,23 @@ namespace boost { namespace fusion
|
||||
|
||||
using base::operator();
|
||||
|
||||
template <typename T>
|
||||
struct result;
|
||||
template <typename Sig>
|
||||
struct result
|
||||
{ };
|
||||
|
||||
template <typename Func>
|
||||
struct result<unfused_generic<Func>()>
|
||||
: base::r0
|
||||
template <class Self>
|
||||
struct result< Self const () >
|
||||
: base::call_const_0_result_class
|
||||
{ };
|
||||
|
||||
template <class Self>
|
||||
struct result< Self() >
|
||||
: base::call_0_result_class
|
||||
{ };
|
||||
|
||||
#define BOOST_FUSION_CODE(tpl_params,arg_types,params,args) \
|
||||
template <tpl_params> \
|
||||
inline typename function::template result<function( \
|
||||
inline typename function::template result<function const ( \
|
||||
BOOST_PP_CAT(fusion::vector,N)<arg_types>)>::type \
|
||||
operator()(params) const \
|
||||
{ \
|
||||
@ -91,16 +97,22 @@ namespace boost { namespace fusion
|
||||
#define N BOOST_PP_ITERATION_1
|
||||
#include BOOST_PP_ITERATE()
|
||||
#undef N
|
||||
|
||||
#undef BOOST_FUSION_CODE
|
||||
};
|
||||
}}
|
||||
|
||||
namespace boost {
|
||||
template<typename Func>
|
||||
struct result_of<boost::fusion::unfused_generic<Func>()>
|
||||
namespace boost
|
||||
{
|
||||
template<class F>
|
||||
struct result_of<boost::fusion::unfused_generic<F> const ()>
|
||||
{
|
||||
typedef boost::fusion::unfused_generic<Func> function;
|
||||
typedef typename function::template result<function()>::type type;
|
||||
typedef typename boost::fusion::unfused_generic<F>::call_const_0_result type;
|
||||
};
|
||||
template<class F>
|
||||
struct result_of<boost::fusion::unfused_generic<F>()>
|
||||
{
|
||||
typedef typename boost::fusion::unfused_generic<F>::call_0_result type;
|
||||
};
|
||||
}
|
||||
|
||||
@ -115,9 +127,17 @@ namespace boost {
|
||||
#include <boost/fusion/functional/adapter/detail/pt_def.hpp>
|
||||
|
||||
#if BOOST_PP_SLOT_1() == 0
|
||||
template <typename Func, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct result
|
||||
<unfused_generic<Func>(BOOST_PP_ENUM_PARAMS(N,T))>
|
||||
< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
|
||||
: function::template result<function const (
|
||||
BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
|
||||
typename detail::gref<T,>::type BOOST_PP_INTERCEPT) >)>
|
||||
{ };
|
||||
|
||||
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct result
|
||||
< Self(BOOST_PP_ENUM_PARAMS(N,T)) >
|
||||
: function::template result<function(BOOST_PP_CAT(fusion::vector,N)<
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::gref<T,>::type
|
||||
BOOST_PP_INTERCEPT) >)>
|
||||
@ -126,7 +146,7 @@ namespace boost {
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
|
||||
template <BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
inline typename function::template result<function(
|
||||
inline typename function::template result<function const(
|
||||
BOOST_PP_CAT(fusion::vector,N)<BOOST_PP_ENUM_PARAMS(N,PT)>)>::type
|
||||
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const
|
||||
{
|
||||
|
@ -55,12 +55,18 @@ namespace boost { namespace fusion
|
||||
|
||||
using base::operator();
|
||||
|
||||
template <typename T>
|
||||
struct result;
|
||||
template <typename Sig>
|
||||
struct result
|
||||
{ };
|
||||
|
||||
template <typename Func>
|
||||
struct result<unfused_lvalue_args<Func>()>
|
||||
: base::r0
|
||||
template <class Self>
|
||||
struct result< Self const () >
|
||||
: base::call_const_0_result_class
|
||||
{ };
|
||||
|
||||
template <class Self>
|
||||
struct result< Self() >
|
||||
: base::call_0_result_class
|
||||
{ };
|
||||
|
||||
#define BOOST_PP_FILENAME_1 \
|
||||
@ -71,12 +77,17 @@ namespace boost { namespace fusion
|
||||
};
|
||||
}}
|
||||
|
||||
namespace boost {
|
||||
template<typename Func>
|
||||
struct result_of<boost::fusion::unfused_lvalue_args<Func>()>
|
||||
namespace boost
|
||||
{
|
||||
template<class F>
|
||||
struct result_of< boost::fusion::unfused_lvalue_args<F> const () >
|
||||
{
|
||||
typedef boost::fusion::unfused_lvalue_args<Func> function;
|
||||
typedef typename function::template result<function()>::type type;
|
||||
typedef typename boost::fusion::unfused_lvalue_args<F>::call_const_0_result type;
|
||||
};
|
||||
template<class F>
|
||||
struct result_of< boost::fusion::unfused_lvalue_args<F>() >
|
||||
{
|
||||
typedef typename boost::fusion::unfused_lvalue_args<F>::call_0_result type;
|
||||
};
|
||||
}
|
||||
|
||||
@ -89,12 +100,18 @@ namespace boost {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
template <typename Func, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct result
|
||||
<Func(BOOST_PP_ENUM_PARAMS(N,T))>
|
||||
: function::template result< function(BOOST_PP_CAT(fusion::vector,N)<
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::mref<T,>::type
|
||||
BOOST_PP_INTERCEPT) >)>
|
||||
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
|
||||
: function::template result< function const (
|
||||
BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
|
||||
typename detail::mref<T,>::type BOOST_PP_INTERCEPT) >)>
|
||||
{ };
|
||||
|
||||
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct result< Self(BOOST_PP_ENUM_PARAMS(N,T)) >
|
||||
: function::template result< function (
|
||||
BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
|
||||
typename detail::mref<T,>::type BOOST_PP_INTERCEPT) >)>
|
||||
{ };
|
||||
|
||||
template <BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
|
@ -55,12 +55,18 @@ namespace boost { namespace fusion
|
||||
|
||||
using base::operator();
|
||||
|
||||
template <typename T>
|
||||
struct result;
|
||||
template <typename Sig>
|
||||
struct result
|
||||
{ };
|
||||
|
||||
template <typename Func>
|
||||
struct result<unfused_rvalue_args<Func>()>
|
||||
: base::r0
|
||||
template <class Self>
|
||||
struct result< Self const () >
|
||||
: base::call_const_0_result_class
|
||||
{ };
|
||||
|
||||
template <class Self>
|
||||
struct result< Self() >
|
||||
: base::call_0_result_class
|
||||
{ };
|
||||
|
||||
#define BOOST_PP_FILENAME_1 \
|
||||
@ -71,12 +77,17 @@ namespace boost { namespace fusion
|
||||
};
|
||||
}}
|
||||
|
||||
namespace boost {
|
||||
template<typename Func>
|
||||
struct result_of<boost::fusion::unfused_rvalue_args<Func>()>
|
||||
namespace boost
|
||||
{
|
||||
template<class F>
|
||||
struct result_of<boost::fusion::unfused_rvalue_args<F> const ()>
|
||||
{
|
||||
typedef boost::fusion::unfused_rvalue_args<Func> function;
|
||||
typedef typename function::template result<function()>::type type;
|
||||
typedef typename boost::fusion::unfused_rvalue_args<F>::call_const_0_result type;
|
||||
};
|
||||
template<class F>
|
||||
struct result_of<boost::fusion::unfused_rvalue_args<F>()>
|
||||
{
|
||||
typedef typename boost::fusion::unfused_rvalue_args<F>::call_0_result type;
|
||||
};
|
||||
}
|
||||
|
||||
@ -89,11 +100,18 @@ namespace boost {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
template <typename Func, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct result<Func(BOOST_PP_ENUM_PARAMS(N,T))>
|
||||
: function::template result<function( BOOST_PP_CAT(fusion::vector,N)<
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::cref<T,>::type
|
||||
BOOST_PP_INTERCEPT) >)>
|
||||
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
|
||||
: function::template result< function const (
|
||||
BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
|
||||
typename detail::cref<T,>::type BOOST_PP_INTERCEPT) >)>
|
||||
{ };
|
||||
|
||||
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct result< Self (BOOST_PP_ENUM_PARAMS(N,T)) >
|
||||
: function::template result< function (
|
||||
BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
|
||||
typename detail::cref<T,>::type BOOST_PP_INTERCEPT) >)>
|
||||
{ };
|
||||
|
||||
template <BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
|
@ -104,12 +104,18 @@ namespace boost { namespace fusion
|
||||
: fnc_transformed(f)
|
||||
{ }
|
||||
|
||||
template <typename T>
|
||||
struct result;
|
||||
template <typename Sig>
|
||||
struct result
|
||||
{ };
|
||||
|
||||
template <typename Func, typename Seq>
|
||||
struct result<unfused_typed<Func, Seq>()>
|
||||
: base::r0
|
||||
template <class Self>
|
||||
struct result< Self const () >
|
||||
: base::call_const_0_result_class
|
||||
{ };
|
||||
|
||||
template <class Self>
|
||||
struct result< Self() >
|
||||
: base::call_0_result_class
|
||||
{ };
|
||||
};
|
||||
|
||||
@ -119,15 +125,21 @@ namespace boost { namespace fusion
|
||||
|
||||
}}
|
||||
|
||||
namespace boost {
|
||||
template<typename Func, typename Seq>
|
||||
struct result_of<boost::fusion::unfused_typed<Func, Seq>()>
|
||||
namespace boost
|
||||
{
|
||||
template<class F, class Seq>
|
||||
struct result_of< boost::fusion::unfused_typed<F,Seq> const () >
|
||||
{
|
||||
typedef boost::fusion::unfused_typed<Func, Seq> function;
|
||||
typedef typename function::template result<function()>::type type;
|
||||
typedef typename boost::fusion::unfused_typed<F,Seq>::call_const_0_result type;
|
||||
};
|
||||
template<class F, class Seq>
|
||||
struct result_of< boost::fusion::unfused_typed<F,Seq>() >
|
||||
{
|
||||
typedef typename boost::fusion::unfused_typed<F,Seq>::call_0_result type;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_TYPED_HPP_INCLUDED
|
||||
#else // defined(BOOST_PP_IS_ITERATING)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -149,26 +161,21 @@ namespace boost {
|
||||
Derived,Function,Sequence>::type base;
|
||||
|
||||
typedef typename remove_const<typename remove_reference<Function>::type>::type function;
|
||||
|
||||
// Notes:
|
||||
// - conversion to fusion::vector might not be perfect (there is
|
||||
// currently no "inrinsic converting ctor" that would allow us
|
||||
// to let the user choose the sequence implementation)
|
||||
// - value_at_c (instead of iteration) is OK because of conversion
|
||||
// to fusion::vector - we would need iteration for arbitrary
|
||||
// sequences
|
||||
typedef typename result_of::as_vector<Sequence>::type arg_vector_t;
|
||||
|
||||
protected:
|
||||
typedef typename function::
|
||||
template result<function const (arg_vector_t)> BOOST_PP_CAT(rc,N);
|
||||
typedef typename function::
|
||||
template result<function(arg_vector_t)> BOOST_PP_CAT(r,N);
|
||||
public:
|
||||
|
||||
using base::operator();
|
||||
|
||||
typedef typename function::
|
||||
template result<function(arg_vector_t)> BOOST_PP_CAT(r,N);
|
||||
|
||||
#define M(z,i,s) \
|
||||
typename call_param<typename result_of::value_at_c<s,i>::type>::type a##i
|
||||
|
||||
inline typename function::template result<function(arg_vector_t)>::type
|
||||
inline typename function::template result<function const (arg_vector_t)>::type
|
||||
operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) const
|
||||
{
|
||||
arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a));
|
||||
@ -190,11 +197,20 @@ namespace boost {
|
||||
} // namespace detail
|
||||
|
||||
template <class Function, class Sequence>
|
||||
template <typename Func, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct unfused_typed<Function,Sequence>::result
|
||||
<Func(BOOST_PP_ENUM_PARAMS(N,T))>
|
||||
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct unfused_typed<Function,Sequence>::result<
|
||||
Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
|
||||
: BOOST_PP_CAT(base::rc,N)
|
||||
{ };
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
|
||||
template <class Function, class Sequence>
|
||||
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
|
||||
struct unfused_typed<Function,Sequence>::result<
|
||||
Self (BOOST_PP_ENUM_PARAMS(N,T)) >
|
||||
: BOOST_PP_CAT(base::r,N)
|
||||
{ };
|
||||
#endif
|
||||
|
||||
#undef N
|
||||
#endif // defined(BOOST_PP_IS_ITERATING)
|
||||
|
@ -38,11 +38,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename Params>
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename B, typename RM, class Seq>
|
||||
struct result<test_func<B, RM>(Seq)>
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{ };
|
||||
|
@ -37,11 +37,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename Params>
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename B, typename RN, class Seq>
|
||||
struct result<test_func<B, RN>(Seq)>
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{ };
|
||||
|
@ -35,11 +35,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename Params>
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename B, typename RN, class Seq>
|
||||
struct result<test_func<B, RN>(Seq)>
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{ };
|
||||
|
@ -35,14 +35,14 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename T>
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename B, typename RN, class Seq>
|
||||
struct result<test_func<B,RN>(Seq)>
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{};
|
||||
{ };
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq) const
|
||||
@ -51,7 +51,7 @@ struct test_func
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
template < typename Seq >
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq)
|
||||
{
|
||||
long state = 100;
|
||||
@ -89,7 +89,7 @@ void result_type_tests()
|
||||
|
||||
BOOST_TEST(( has_type< test_func_0::result<test_func_0()> >::value ));
|
||||
BOOST_TEST(( has_type< test_func_1::result<test_func_1(int)> >::value ));
|
||||
BOOST_TEST(( ! has_type< test_func_1::result<test_func_1()> >::value ));
|
||||
BOOST_TEST(( ! has_type< test_func_1::result<test_func_1() > >::value ));
|
||||
BOOST_TEST(( is_same< boost::result_of< test_func_0() >::type, long >::value ));
|
||||
BOOST_TEST(( is_same< boost::result_of< test_func_1(int) >::type, long >::value ));
|
||||
}
|
||||
@ -112,8 +112,12 @@ int main()
|
||||
BOOST_TEST(unfused_func_c_ref() == 0);
|
||||
|
||||
long lvalue = 12;
|
||||
// also test const lvalues to pick up compiler deficiencies in that area
|
||||
int const clvalue_1 = 1;
|
||||
long const clvalue_2 = 2;
|
||||
|
||||
static const long expected = 1*sizeof(int) + 2*sizeof(long) + 7*sizeof(char);
|
||||
BOOST_TEST(unfused_func(lvalue,lvalue,1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(unfused_func(lvalue,lvalue,clvalue_1,clvalue_2,'\007') == 100 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 2*sizeof(long));
|
||||
BOOST_TEST(unfused_func_ref(lvalue,lvalue,1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 4*sizeof(long));
|
||||
|
@ -32,11 +32,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename T>
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename B, typename RM, class Seq>
|
||||
struct result<test_func<B, RM>(Seq)>
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{ };
|
||||
@ -48,7 +48,7 @@ struct test_func
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
template < typename Seq >
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq)
|
||||
{
|
||||
long state = 100;
|
||||
|
@ -32,11 +32,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename T>
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename B, typename RN, class Seq>
|
||||
struct result<test_func<B, RN>(Seq)>
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{ };
|
||||
|
@ -45,8 +45,8 @@ struct test_func
|
||||
template<typename T>
|
||||
struct result;
|
||||
|
||||
template <typename B, typename V, class Seq>
|
||||
struct result<test_func<B,V>(Seq)>
|
||||
template <class Self, class Seq>
|
||||
struct result<Self(Seq)>
|
||||
: mpl::if_< typename mpl::apply<Validation, Seq>::type,
|
||||
mpl::identity<long>, boost::blank >::type
|
||||
{ };
|
||||
|
Reference in New Issue
Block a user