
AMDG On 2/7/2011 1:52 PM, Lorenzo Caminiti wrote:
Too bad I don't think I can actually do this :( (given that `void` can be _any_ token so I cannot strip it out with the pp...). I might be able however to pull the return type outside the macro as in Alex-Steven's syntax:
void BOOST_LOCAL_FUNCTION(int x, double& y, const bind a, // [14] const bind& b, bind& c, bind d) { ... } BOOST_LOCAL_FUNCTION_END(f) f(1, 1.23);
And regardless of what Alex-Steven did, I could do this by expanding to a dummy variable/expression and then get its type with typeof (but the library will then require typeof to determine the result type even when no bound parameter is used and for a type which is specified by programmes as a type -- that'd be strange):
void *result_ptr; // Plus append __LINE__... typedef typeof(*result_ptr) result_type; ...
That's almost what we did. void deduce_result(); typedef boost::function_traits< typeof(&deduce_result)>::result_type result_type; is a little better. (It can handle references.) In Christ, Steven Watanabe