Boost logo

Boost :

Subject: Re: [boost] result_of overloaded member function?
From: Joachim Faulhaber (afojgo_at_[hidden])
Date: 2011-05-04 11:02:56


2011/5/4 Arno Schödl <aschoedl_at_[hidden]>:
> Hello,
>
>
>
> is there a way to get the result type of an overloaded member function? Something like:
>
>
>
> template< class T, class A >
>
> typename boost::result_of< T::func(A) >::type invoke( T& t, A& a ) {
>
> return t.func(a);
>
> }
>

Would this be helpful?

class C
{
public:
        int f(int);
        float f(int, float);
};

BOOST_AUTO_TEST_CASE(decl_type)
{
BOOST_CHECK((boost::is_same< int, decltype( C().f(0) )>::value));
BOOST_CHECK((boost::is_same<float, decltype( C().f(0, 0.0) )>::value));
}

Regards,
Joachim

-- 
Interval Container Library [Boost.Icl]
http://www.joachim-faulhaber.de

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk