::type arg_signature;
Hi,
I was looking for a way to convert a member function type:
bool (X::*)(int) or bool (X::)(int)
to the 'C' equivalent, without the class pointer:
bool (*)(int) or bool(int)
Now, I used this helper class:
// Converts R (X::)(Args) to R (Args)
template<class F>
class UnMember
{
typedef boost::function_type_signature<F> member_signature;
typedef typename boost::mpl::erase::type>::type>::type non_member_signature;
public:
typedef typename
boost::function_typeboost::plain_function,non_member_signature::type type;
};
And use it like:
typedef UnMember::type PlainFunctionType;
It gets even complexer when one wants to convert a member function type to a
function type which takes the member as first argument:
// Converts R (X::)(Args) to R (X::*, Args)
template<class F>
class MemberToFirstArg
{
typedef boost::function_type_signature<F> member_signature;
// remove the class from the arg list:
typedef typename boost::mpl::erase::type>::type>::type non_member_signature;
// insert it as first argument.
typedef typename boost::mpl::insert::type>::type,
typename boost::add_pointer >::type>::type
public:
typedef typename
boost::function_typeboost::plain_function,arg_signature::type type;
};
Is there an easier way to do this ? Does a boost library have a mechanism to
convert member function types to non-member function types and vice versa ?
Peter
--
Peter Soetens -- FMTC -- http://www.fmtc.be