Boost logo

Boost :

Subject: Re: [boost] [local] Simplifying the parenthesized syntax
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-02-07 17:29:58


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


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