|
Boost : |
Subject: Re: [boost] Interest in Remote Procedure Call Library?
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2010-02-13 01:37:11
On Feb 7, 2010, at 3:08 PM, vicente.botet wrote:
> BTW, the interface you presented initialy was really simple.
>
> META_INTERFACE( SomeClass,
> METHOD(add)
> METHOD(sub)
> METHOD(inout)
> )
>
> And was able to get the single function signature for add. I don't know which techniques do you use to get this, but can't the same techniques get all the signatures sharing the same function name? Could you explain how do you get the complete signature?
I didn't see this question initially... but to answer how I accomplished that "black magic"...
Given macro parameters CLASS and METHOD_NAME
The signature can be determined using boost TYPE_OF and the following trick:
BOOST_TYPEOF( testFunc(&CLASS::METHOD_NAME) )
template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(n,typename A), typename C>
boost::function_traits<R(BOOST_PP_ENUM_PARAMS(n,A))> testFunc( R (C::*)(BOOST_PP_ENUM_PARAMS(n,A) );
Then using the equivalent of Boost.Mirror get_typename<T>::str() I can deduce the string equivalent of each parameter type.
The reason I cannot do it with overloads is because the call to testFunc(&X::Y) become ambiguous for because there are two possible matches for testFunc(&X::Y), additionally if the user only wanted to register one of the overloads and not the other then they would have no means to identify which ones they want.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk