|
Boost Users : |
From: Delfin Rojas (drojas_at_[hidden])
Date: 2005-04-27 17:48:22
I think I found the solution to my problem. If I add the following to my
program:
namespace boost
{
namespace detail
{
/** Fix for boost::result_of */
template<typename R, typename FArgs , typename T0>
struct result_of<R (T0::*)(), FArgs>
{
typedef R type;
};
/** Fix for boost::result_of */
template<typename R, typename FArgs , typename T0>
struct result_of<R (T0::*)() const, FArgs>
{
typedef R type;
};
} //namespace detail
} //namespace boost
Then boost::result_of "learns" how to detect the result type of a member
function signature with no parameters. Now the question is: why is this
specialization not provided by boost? Should it be?
Thanks
-delfin
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Delfin Rojas
> Sent: Wednesday, April 27, 2005 2:22 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] Function pointers, result_of<> and
> function_traits<>
>
> Hello all,
>
> I am trying to get the return type of a member function given its
> signature.
> Consider the following example from the boost result_of test:
>
> struct X {};
>
> int main
> {
> using namespace boost;
> typedef int (X::*mem_func_ptr)(float);
>
> BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr(X,char)>::type,
> int>::value));
> }
>
> This test compiles/runs with no problems. Now, what I want is the return
> type of a function with signature "int (X::*)()"
>
> I added the following to the test:
>
> typedef int (X::*empty_mem_func_ptr)();
>
> BOOST_STATIC_ASSERT((is_same<result_of<empty_mem_func_ptr(X)>::type,
> int>::value));
>
> This does not compile. I get an error
> boost_1_32_0\boost\utility\result_of.hpp(43) : error C2825: 'F::template':
> cannot form a qualified name.
>
> I tried to do this same thing with function_traits but it seems function
> traits does not support member function pointers at all.
>
> So this is all I have. If somebody can help me I would appreciate it.
>
> Thanks
>
> -delfin
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
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