Boost logo

Boost Users :

Subject: Re: [Boost-users] functors with function_traits
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-09-18 17:17:35


AMDG

Christoph wrote:
> Do function_traits work with functors?
>
>
> I tried with
>
> struct XYZ
> {
> bool operator() (int x) const { return x+2; }
> };
>
>
> <snip>
>

Err, what do you want to happen for an overloaded or templated
function object?

struct f {
    template<class T>
    void operator()(const T&) const;
};

> Is there a way to achieve the function_traits functionality with
> function_traits or some other type_traits?
>

You can try

typedef BOOST_TYPEOF(FUNCTION::operator()) mf_type;

Then mf_type will be (e.g.) int (XYZ::*)(int) const, which can be
broken down by the Function Types library.

In Christ,
Steven Watanabe


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