Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::function typename Signature
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2009-09-18 13:02:29


On Fri, Sep 18, 2009 at 8:37 AM, veerus <veeranjaneyulu.sadhanala_at_[hidden]> wrote:
>
> How to extract the return type and the argument type list from the type
> Signature in
> boost::function<Signature> ?
>
> More specifically if I have a object of type boost::function< int ( double)
>>,  the thing "int (double)" is matched with a type. What type is that ?
> Where can I find it?
>

Sounds like same thing I ran into. Is this what you are looking for:

// for some reason boost::function_types does not handle boost::functions,
// nor does boost::function have a function::signature typedef,
// so in order to support boost, we use this signature<F>::type mechanism:
template <typename F>
struct signature
{
    typedef F type;
};
// specialize for boost::function
template <typename F>
struct signature<boost::function<F> >
{
    typedef F type;
};

template <typename F>
struct result_type
{
    typedef typename boost::function_types::result_type<typename
signature<F>::type>::type type;
};

So
signature<F>::type returns (for example) 'int (double)' for normal
functions as well as boost functions
similarly, result_type<F>::type returns 'int'

Tony


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net