Boost logo

Boost :

Subject: Re: [boost] Checking for return types (result_of) - redux..
From: Edward Grace (ej.grace_at_[hidden])
Date: 2009-08-21 10:37:35


On 21 Aug 2009, at 15:07, Frank Mori Hess wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Friday 21 August 2009, Edward Grace wrote:
>> boost::result_of<O()>::type
>
> I don't have experience with boost::result_of,

Me neither... Well, if you don't count the last couple of hours.

> but is it right to add
> parenthesis?

I don't think so, from the doc:

"Given an lvalue f of type F and lvalues t1, t2, ..., tN of types T1,
T2, ..., TN, respectively, the type result_of<F(T1, T2, ..., TN)
>::type defines the result type of the expression f(t1, t2, ...,tN). "

Since my function/functors take no arguments I took that to mean,
assuming a function 'o' corresponding to the funtion type O

   result_of<O()>::type

should resolve to the result (return type) of doing 'o()' - the
function o(). This does appear to be the case in the code I
submitted, at least for the ordinary functions. If I omit the
parentheses then it compares the type of O (a function pointer
returning an unsigned int) and unsigned int -- not what I want.

Perhaps 'result type' and 'return type' are two subtly different
things in this context.

> That looks to me like you are asking for the return type of a
> function type that takes no arguments and returns an object of type O.

I don't think so - but I'm a little stumped...

-ed




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