I hope the sheer size of this post doesn't scare those who can help me
away :(
Depending on how I use the code at the bottom of this post, things
either work or they blow up with varying error messages deep within the
boost libraries. The very last function in the code below is the last
consistent "source" of the errors. As best as I understand it, that
line is correct. I'm scratching my head on how to diagnose what's going
wrong.
The simplest error I got seemed to complain about const qualifiers that
seem to have been added internally to boost::lambda::bind. I'm not sure
which error message to pick out from other error scenarios (such as 3
input parameters (types T0, T1, and T2)). This error had R0=void, and
no input arguments (T0, T1, etc...). The code at the bottom of this
post compiles with R0=void and T0=int.
actions.hpp:87: error: no matching function for call to
‘boost::lambda::function_adaptor<
GTPInternalResponse (*)(
boost::function0
#include
// expands for 0 ... N-1 #include // expands for 1 ... N-1 #if GTP_PARAM_COUNT == 0 # define GTP_OPTIONAL_COMMA #else # define GTP_OPTIONAL_COMMA , #endif
// GTP_PARMS expands to " typename T0, typename T1, typename T2" if GTP_PARAM_COUNT is 3 #define GTP_TEMPLATE_PARAMS BOOST_PP_ENUM_PARAMS(GTP_PARAM_COUNT, typename T)
// expands to "typename R0 , typename T0, typename T1, typename T2" if GTP_PARAM_COUNT is 3 #define GTP_FULL_TEMPLATE_PARAMS typename R0 GTP_OPTIONAL_COMMA GTP_TEMPLATE_PARAMS
// GTP_PARAM expands to " T3 a3" if INDEX is 3 #define GTP_PARAM(UNKNOWN1,INDEX,UNKNOWN2) BOOST_PP_CAT(T,I) BOOST_PP_CAT(a,I)
// GTP_PARAMS expands to " T0 a0, T1 a1, T2 a2" if GTP_PARAM_COUNT is 3 #define GTP_PARAMS BOOST_PP_ENUM(GTP_PARAM_COUNT,GTP_PARAM,BOOST_PP_EMPTY)
// GTP_PARAM_TYPES expands to " T0, T1, T2" if GTP_PARAM_COUNT is 3 #define GTP_PARAM_TYPES BOOST_PP_ENUM_PARAMS(GTP_PARAM_COUNT, T)
// expands to "R0 , T0, T1, T2" if GTP_PARAM_COUNT is 3 #define GTP_FULL_PARAM_TYPES R0 GTP_OPTIONAL_COMMA GTP_PARAM_TYPES
// GTP_PARAM_NAMES expands to " a0, a1, a2" if GTP_PARAM_COUNT is 3 #define GTP_PARAM_NAMES BOOST_PP_ENUM_PARAMS(GTP_PARAM_COUNT, a)
// expands to "boost::function3 < R0 , T0, T1, T2 >" when GTP_PARAM_COUNT is 3 #define GTP_BOOST_FUNCTION BOOST_PP_CAT(boost::function,GTP_PARAM_COUNT) < GTP_FULL_PARAM_TYPES >
// expands to "boost::function3 < void , T0, T1, T2 >" when GTP_PARAM_COUNT is 3 #define GTP_BOOST_FUNCTION_VOID BOOST_PP_CAT(boost::function,GTP_PARAM_COUNT) < void GTP_OPTIONAL_COMMA GTP_PARAM_TYPES >
// expands to type_wrapper3 when GTP_PARAM_COUNT is 3 #define GTP_TYPE_WRAPPER BOOST_PP_CAT(type_wrapper,GTP_PARAM_COUNT)
////////////////////////////////////////////////////////////// // gtp_detail::type_wrapper for converting all input arguments namespace gtp_detail{
template < GTP_FULL_TEMPLATE_PARAMS > struct GTP_TYPE_WRAPPER{ static GTPInternalResponse wrap(GTP_BOOST_FUNCTION *(callback_function), GTPCommand cmd){ unsigned int position = 0; /// \bug Must figure out how to auto generate this repetative body #if GTP_PARAM_COUNT >= 1 assert(position < cmd.GetArgumentCount()); T0 a0 = extract<T0>(cmd, position); #endif #if GTP_PARAM_COUNT >= 2 assert(position < cmd.GetArgumentCount()); T1 a1 = extract<T1>(cmd,position); #endif #if GTP_PARAM_COUNT >= 3 assert(position < cmd.GetArgumentCount()); T2 a2 = extract<T2>(cmd,position); #endif assert(position == cmd.GetArgumentCount()); return converter
( (*callback_function)(GTP_PARAM_NAMES) ); } }; template < GTP_TEMPLATE_PARAMS > struct GTP_TYPE_WRAPPER < void GTP_OPTIONAL_COMMA GTP_PARAM_TYPES >{ static GTPInternalResponse wrap(GTP_BOOST_FUNCTION_VOID *(callback_function), GTPCommand cmd){ unsigned int position = 0; /// \bug Must figure out how to auto generate this repetative body #if GTP_PARAM_COUNT >= 1 assert(position < cmd.GetArgumentCount()); T0 a0 = extract<T0>(cmd, position); #endif #if GTP_PARAM_COUNT >= 2 assert(position < cmd.GetArgumentCount()); T1 a1 = extract<T1>(cmd,position); #endif #if GTP_PARAM_COUNT >= 3 assert(position < cmd.GetArgumentCount()); T2 a2 = extract<T2>(cmd,position); #endif assert(position == cmd.GetArgumentCount()); (*callback_function)(GTP_PARAM_NAMES); return GTPInternalResponse(); } };
};
/////////////////////////////////////////////////////// // GTPCommandCallBack accepting a boost function object
// expands to GTPFunctionObject3 when GTP_PARAM_COUNT is 3 #define GTP_COMMAND_CALLBACK BOOST_PP_CAT(GTPCommandCallBack,GTP_PARAM_COUNT)
// expands to " boost::lambda::_1, boost::lambda::_2, boost::lambda::_3" if GTP_PARAM_COUNT is 3 #define GTP_LAMBDA_PARAMS BOOST_PP_ENUM_SHIFTED_PARAMS(GTP_PARAM_COUNT_PLUS_ONE, boost::lambda::_)
template< GTP_FULL_TEMPLATE_PARAMS > inline GTPFunctionObject* GTP_COMMAND_CALLBACK(GTP_BOOST_FUNCTION *callback_function){ return new GTPFunctionObject(boost::lambda::bind((>p_detail::GTP_TYPE_WRAPPER
::wrap), callback_function GTP_OPTIONAL_COMMA GTP_LAMBDA_PARAMS)); }