Boost logo

Boost :

Subject: Re: [boost] [utility][thread] result_of - erroneous result type from a C++11 lambda
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2013-06-17 14:27:13


On Mon, Jun 17, 2013 at 8:06 PM, Daniel Walker <daniel.j.walker_at_[hidden]>wrote:

> If I'm not mistaken, it looks like you are using the TR1 protocol with
> nullary functions. See the bullet point on nullary functions in the
> documentation.
>
>
> http://www.boost.org/doc/libs/1_53_0/libs/utility/utility.htm#result_of_tr1_diff
>
> TR1 cannot deduce the return type of nullary function objects. You
> probably either want to use std::result_of or boost::result_of with
> BOOST_RESULT_OF_USE_DECLTYPE defined. If you really must use TR1 there are
> workarounds for the nullary function issue discussed at the same bullet
> point at the link above, but these workarounds may not be applicable in
> your situation. In C++11, I would not recommend using TR1 unless you need
> it for backwards compatibility/portability to C++03, in which case you
> can't deduce return types for nullary function objects.
>

In my own VS2012 code I use decltype exclusively.

But that do not fix the problem for boost libraries themselves:
Boost.Thread (future, async) apparently uses boost::result_of which makes
the two first example I provide go wrong and
makes both async and .then unusable.
My understanding was that indeed these libraries would automatically use
decltype() in the implementation if available, not tr1::result_of or
something else.
Is automatically BOOST_RESULT_OF_USE_DECLTYPE defined for VS2012? If not
isn't it a bug? decltype is available whatever the compilation flags you
use.

Joel lamotte


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