completes boost::result_of-based result type computation

[SVN r38194]
This commit is contained in:
Tobias Schwinger
2007-07-12 09:08:46 +00:00
parent 046d853d63
commit 8eda5d32ca
16 changed files with 305 additions and 156 deletions

View File

@ -26,43 +26,101 @@ namespace boost { namespace fusion { namespace detail
template<typename Function> template<typename Function>
struct get_result_spec struct get_result_spec
{ {
typedef typename remove_const<typename remove_reference<Function>::type>::type function; private:
typedef typename function::template result<function(fusion::vector0)> type; 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< template <class Derived, class Function,
typename get_result_spec<Function>::type>::value> 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 struct nullary_call_base
{ {
template <typename T> inline void operator()(T reserved::*) const { }
protected: 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> typedef typename get_result_spec<Function>::call_0_result
struct nullary_call_base<Derived,Function,true> call_0_result_class;
{
private:
typedef typename remove_const<typename remove_reference<Function>::type>::type function;
protected:
typedef typename function::template result<function(vector0)> r0;
public: public:
typedef typename call_const_0_result_class::type
call_const_0_result;
inline typename r0::type inline call_const_0_result operator()() const
operator()() const
{ {
fusion::vector0 arg; fusion::vector0 arg;
return static_cast<Derived const *>(this)->fnc_transformed(arg); return static_cast<Derived const *>(this)->fnc_transformed(arg);
} }
inline typename r0::type typedef typename get_result_spec<Function>::call_0_result::type
operator()() call_0_result;
inline call_0_result operator()()
{ {
fusion::vector0 arg; fusion::vector0 arg;
return static_cast<Derived *>(this)->fnc_transformed(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 #endif

View File

@ -35,40 +35,47 @@ namespace boost { namespace fusion
{ } { }
template <class Seq> 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 operator()(Seq const & s) const
{ {
return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s); return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
} }
template <class Seq> 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) operator()(Seq const & s)
{ {
return fusion::invoke<func_fwd_t>(this->fnc_transformed,s); return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
} }
template <class Seq> 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 operator()(Seq & s) const
{ {
return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s); return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
} }
template <class Seq> template <class Seq>
inline typename result_of::invoke<Function,Seq>::type inline typename result_of::invoke<func_fwd_t,Seq>::type
operator()(Seq & s) operator()(Seq & s)
{ {
return fusion::invoke<func_fwd_t>(this->fnc_transformed,s); return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
} }
template<typename T> template <typename Sig>
struct result; struct result
template <typename Func, class Seq>
struct result<fused<Func>(Seq)>
: result_of::invoke<Function,Seq>
{ }; { };
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>
{ };
}; };
}} }}

View File

@ -35,16 +35,16 @@ namespace boost { namespace fusion
{ } { }
template <class Seq> template <class Seq>
inline typename result_of::invoke_function_object<Function,Seq const inline typename result_of::invoke_function_object<func_const_fwd_t,
>::type operator()(Seq const & s) const Seq const>::type operator()(Seq const & s) const
{ {
return fusion::invoke_function_object< return fusion::invoke_function_object<
func_const_fwd_t >(this->fnc_transformed,s); func_const_fwd_t >(this->fnc_transformed,s);
} }
template <class Seq> template <class Seq>
inline typename result_of::invoke_function_object<Function,Seq const inline typename result_of::invoke_function_object<func_fwd_t,
>::type Seq const>::type
operator()(Seq const & s) operator()(Seq const & s)
{ {
return fusion::invoke_function_object< return fusion::invoke_function_object<
@ -52,7 +52,8 @@ namespace boost { namespace fusion
} }
template <class Seq> 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 operator()(Seq & s) const
{ {
return fusion::invoke_function_object< return fusion::invoke_function_object<
@ -60,7 +61,7 @@ namespace boost { namespace fusion
} }
template <class Seq> 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) operator()(Seq & s)
{ {
return fusion::invoke_function_object< return fusion::invoke_function_object<
@ -68,11 +69,17 @@ namespace boost { namespace fusion
} }
template<typename T> template<typename T>
struct result; struct result
{ };
template <typename Seq> template <class Self, class Seq>
struct result<fused_function_object(Seq)> struct result< Self const (Seq) >
: result_of::invoke_function_object<Function, 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>
{ }; { };
}; };

View File

@ -35,43 +35,42 @@ namespace boost { namespace fusion
{ } { }
template <class Seq> template <class Seq>
inline typename result_of::invoke_procedure<Function,Seq const>::type inline void operator()(Seq const & s) const
operator()(Seq const & s) const
{ {
return fusion::invoke_procedure< fusion::invoke_procedure<
func_const_fwd_t >(this->fnc_transformed,s); func_const_fwd_t >(this->fnc_transformed,s);
} }
template <class Seq> template <class Seq>
inline typename result_of::invoke_procedure<Function,Seq const>::type inline void operator()(Seq const & s)
operator()(Seq const & s)
{ {
return fusion::invoke_procedure< fusion::invoke_procedure<
func_fwd_t >(this->fnc_transformed,s); func_fwd_t >(this->fnc_transformed,s);
} }
template <class Seq> template <class Seq>
inline typename result_of::invoke_procedure<Function,Seq>::type inline void operator()(Seq & s) const
operator()(Seq & s) const
{ {
return fusion::invoke_procedure< fusion::invoke_procedure<
func_const_fwd_t >(this->fnc_transformed,s); func_const_fwd_t >(this->fnc_transformed,s);
} }
template <class Seq> template <class Seq>
inline typename result_of::invoke_procedure<Function,Seq>::type inline void operator()(Seq & s)
operator()(Seq & s)
{ {
return fusion::invoke_procedure< return fusion::invoke_procedure<
func_fwd_t >(this->fnc_transformed,s); func_fwd_t >(this->fnc_transformed,s);
} }
template <class Seq> template <typename Sig>
struct result struct result
: result_of::invoke_procedure<Function,Seq>
{ }; { };
typedef void result_type; template <class Self, class Seq>
struct result< Self(Seq) >
{
typedef void type;
};
}; };
}} }}

View File

@ -31,6 +31,9 @@
# elif BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE # elif BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE
# error "BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" # error "BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE"
# endif # endif
# if !defined(BOOST_FUSION_CONSTRUCTOR_MAX_ARITY)
# define BOOST_FUSION_CONSTRUCTOR_MAX_ARITY 6
# endif
#endif #endif

View File

@ -56,17 +56,23 @@ namespace boost { namespace fusion
using base::operator(); using base::operator();
template <typename T> template <typename Sig>
struct result; struct result
{ };
template <typename Func> template <class Self>
struct result<unfused_generic<Func>()> struct result< Self const () >
: base::r0 : 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) \ #define BOOST_FUSION_CODE(tpl_params,arg_types,params,args) \
template <tpl_params> \ 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 \ BOOST_PP_CAT(fusion::vector,N)<arg_types>)>::type \
operator()(params) const \ operator()(params) const \
{ \ { \
@ -91,16 +97,22 @@ namespace boost { namespace fusion
#define N BOOST_PP_ITERATION_1 #define N BOOST_PP_ITERATION_1
#include BOOST_PP_ITERATE() #include BOOST_PP_ITERATE()
#undef N #undef N
#undef BOOST_FUSION_CODE #undef BOOST_FUSION_CODE
}; };
}} }}
namespace boost { namespace boost
template<typename Func> {
struct result_of<boost::fusion::unfused_generic<Func>()> template<class F>
struct result_of<boost::fusion::unfused_generic<F> const ()>
{ {
typedef boost::fusion::unfused_generic<Func> function; typedef typename boost::fusion::unfused_generic<F>::call_const_0_result type;
typedef typename function::template result<function()>::type 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> #include <boost/fusion/functional/adapter/detail/pt_def.hpp>
#if BOOST_PP_SLOT_1() == 0 #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 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)< : function::template result<function(BOOST_PP_CAT(fusion::vector,N)<
BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::gref<T,>::type BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::gref<T,>::type
BOOST_PP_INTERCEPT) >)> BOOST_PP_INTERCEPT) >)>
@ -126,7 +146,7 @@ namespace boost {
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400)) #if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
template <BOOST_PP_ENUM_PARAMS(N,typename T)> 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 BOOST_PP_CAT(fusion::vector,N)<BOOST_PP_ENUM_PARAMS(N,PT)>)>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const
{ {

View File

@ -55,12 +55,18 @@ namespace boost { namespace fusion
using base::operator(); using base::operator();
template <typename T> template <typename Sig>
struct result; struct result
{ };
template <typename Func> template <class Self>
struct result<unfused_lvalue_args<Func>()> struct result< Self const () >
: base::r0 : base::call_const_0_result_class
{ };
template <class Self>
struct result< Self() >
: base::call_0_result_class
{ }; { };
#define BOOST_PP_FILENAME_1 \ #define BOOST_PP_FILENAME_1 \
@ -71,12 +77,17 @@ namespace boost { namespace fusion
}; };
}} }}
namespace boost { namespace boost
template<typename Func> {
struct result_of<boost::fusion::unfused_lvalue_args<Func>()> template<class F>
struct result_of< boost::fusion::unfused_lvalue_args<F> const () >
{ {
typedef boost::fusion::unfused_lvalue_args<Func> function; typedef typename boost::fusion::unfused_lvalue_args<F>::call_const_0_result type;
typedef typename function::template result<function()>::type 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() #define N BOOST_PP_ITERATION()
template <typename Func, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct result struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
<Func(BOOST_PP_ENUM_PARAMS(N,T))> : function::template result< function const (
: function::template result< function(BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::mref<T,>::type typename detail::mref<T,>::type BOOST_PP_INTERCEPT) >)>
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)> template <BOOST_PP_ENUM_PARAMS(N,typename T)>

View File

@ -55,12 +55,18 @@ namespace boost { namespace fusion
using base::operator(); using base::operator();
template <typename T> template <typename Sig>
struct result; struct result
{ };
template <typename Func> template <class Self>
struct result<unfused_rvalue_args<Func>()> struct result< Self const () >
: base::r0 : base::call_const_0_result_class
{ };
template <class Self>
struct result< Self() >
: base::call_0_result_class
{ }; { };
#define BOOST_PP_FILENAME_1 \ #define BOOST_PP_FILENAME_1 \
@ -71,12 +77,17 @@ namespace boost { namespace fusion
}; };
}} }}
namespace boost { namespace boost
template<typename Func> {
struct result_of<boost::fusion::unfused_rvalue_args<Func>()> template<class F>
struct result_of<boost::fusion::unfused_rvalue_args<F> const ()>
{ {
typedef boost::fusion::unfused_rvalue_args<Func> function; typedef typename boost::fusion::unfused_rvalue_args<F>::call_const_0_result type;
typedef typename function::template result<function()>::type 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() #define N BOOST_PP_ITERATION()
template <typename Func, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct result<Func(BOOST_PP_ENUM_PARAMS(N,T))> struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
: function::template result<function( BOOST_PP_CAT(fusion::vector,N)< : function::template result< function const (
BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::cref<T,>::type BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
BOOST_PP_INTERCEPT) >)> 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)> template <BOOST_PP_ENUM_PARAMS(N,typename T)>

View File

@ -104,12 +104,18 @@ namespace boost { namespace fusion
: fnc_transformed(f) : fnc_transformed(f)
{ } { }
template <typename T> template <typename Sig>
struct result; struct result
{ };
template <typename Func, typename Seq> template <class Self>
struct result<unfused_typed<Func, Seq>()> struct result< Self const () >
: base::r0 : 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 { namespace boost
template<typename Func, typename Seq> {
struct result_of<boost::fusion::unfused_typed<Func, Seq>()> 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 boost::fusion::unfused_typed<F,Seq>::call_const_0_result type;
typedef typename function::template result<function()>::type 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 #define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_TYPED_HPP_INCLUDED
#else // defined(BOOST_PP_IS_ITERATING) #else // defined(BOOST_PP_IS_ITERATING)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -149,26 +161,21 @@ namespace boost {
Derived,Function,Sequence>::type base; Derived,Function,Sequence>::type base;
typedef typename remove_const<typename remove_reference<Function>::type>::type function; 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; 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: public:
using base::operator(); using base::operator();
typedef typename function::
template result<function(arg_vector_t)> BOOST_PP_CAT(r,N);
#define M(z,i,s) \ #define M(z,i,s) \
typename call_param<typename result_of::value_at_c<s,i>::type>::type a##i 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 operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) const
{ {
arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a)); arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a));
@ -190,11 +197,20 @@ namespace boost {
} // namespace detail } // namespace detail
template <class Function, class Sequence> template <class Function, class Sequence>
template <typename Func, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct unfused_typed<Function,Sequence>::result struct unfused_typed<Function,Sequence>::result<
<Func(BOOST_PP_ENUM_PARAMS(N,T))> 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) : BOOST_PP_CAT(base::r,N)
{ }; { };
#endif
#undef N #undef N
#endif // defined(BOOST_PP_IS_ITERATING) #endif // defined(BOOST_PP_IS_ITERATING)

View File

@ -38,11 +38,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
struct test_func struct test_func
: Base : Base
{ {
template<typename Params> template <typename Sig>
struct result; struct result;
template <typename B, typename RM, class Seq> template <class Self, class Seq>
struct result<test_func<B, RM>(Seq)> struct result< Self(Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{ }; { };

View File

@ -37,11 +37,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
struct test_func struct test_func
: Base : Base
{ {
template<typename Params> template <typename Sig>
struct result; struct result;
template <typename B, typename RN, class Seq> template <class Self, class Seq>
struct result<test_func<B, RN>(Seq)> struct result< Self(Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{ }; { };

View File

@ -35,11 +35,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
struct test_func struct test_func
: Base : Base
{ {
template<typename Params> template <typename Sig>
struct result; struct result;
template <typename B, typename RN, class Seq> template <class Self, class Seq>
struct result<test_func<B, RN>(Seq)> struct result< Self(Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{ }; { };

View File

@ -35,14 +35,14 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
struct test_func struct test_func
: Base : Base
{ {
template<typename T> template <typename Sig>
struct result; struct result;
template <typename B, typename RN, class Seq> template <class Self, class Seq>
struct result<test_func<B,RN>(Seq)> struct result< Self(Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{}; { };
template <typename Seq> template <typename Seq>
long operator()(Seq const & seq) const long operator()(Seq const & seq) const
@ -51,7 +51,7 @@ struct test_func
return fusion::fold(seq, state, fold_op()); return fusion::fold(seq, state, fold_op());
} }
template < typename Seq > template <typename Seq>
long operator()(Seq const & seq) long operator()(Seq const & seq)
{ {
long state = 100; 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_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(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_0() >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_1(int) >::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); BOOST_TEST(unfused_func_c_ref() == 0);
long lvalue = 12; 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); 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(lvalue == 12 + 2*sizeof(long));
BOOST_TEST(unfused_func_ref(lvalue,lvalue,1,2l,'\007') == 100 + expected); BOOST_TEST(unfused_func_ref(lvalue,lvalue,1,2l,'\007') == 100 + expected);
BOOST_TEST(lvalue == 12 + 4*sizeof(long)); BOOST_TEST(lvalue == 12 + 4*sizeof(long));

View File

@ -32,11 +32,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
struct test_func struct test_func
: Base : Base
{ {
template<typename T> template <typename Sig>
struct result; struct result;
template <typename B, typename RM, class Seq> template <class Self, class Seq>
struct result<test_func<B, RM>(Seq)> struct result< Self(Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{ }; { };
@ -48,7 +48,7 @@ struct test_func
return fusion::fold(seq, state, fold_op()); return fusion::fold(seq, state, fold_op());
} }
template < typename Seq > template <typename Seq>
long operator()(Seq const & seq) long operator()(Seq const & seq)
{ {
long state = 100; long state = 100;

View File

@ -32,11 +32,11 @@ template <class Base = boost::blank, class RemoveNullary = mpl::false_>
struct test_func struct test_func
: Base : Base
{ {
template<typename T> template <typename Sig>
struct result; struct result;
template <typename B, typename RN, class Seq> template <class Self, class Seq>
struct result<test_func<B, RN>(Seq)> struct result< Self(Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{ }; { };

View File

@ -45,8 +45,8 @@ struct test_func
template<typename T> template<typename T>
struct result; struct result;
template <typename B, typename V, class Seq> template <class Self, class Seq>
struct result<test_func<B,V>(Seq)> struct result<Self(Seq)>
: mpl::if_< typename mpl::apply<Validation, Seq>::type, : mpl::if_< typename mpl::apply<Validation, Seq>::type,
mpl::identity<long>, boost::blank >::type mpl::identity<long>, boost::blank >::type
{ }; { };