Boost logo

Boost :

Subject: Re: [boost] [Phoenix] lambda_tests.test fails on gcc 4.3-4.8 with BOOST_RESULT_OF_USE_DECLTYPE
From: Eric Niebler (eric_at_[hidden])
Date: 2012-10-06 11:31:26


On 10/5/2012 10:50 PM, Michel Morin wrote:
> First, thanks Eric for fixing incompatibility between Phoenix and
> decltype-based result_of. This is really a great fix!
>
> I ran Phoenix test-suite on * clang 3.1, 3.2 (trunk) * gcc 4.4-4.7,
> 4.8 (experimental) with * C++03, C++11 +
> BOOST_RESULT_OF_USE_DECLTYPE, C++11 + BOOST_RESULT_OF_USE_TR1
>
> The only failure is lambda_tests.test (i.e.
> scope/lambda_tests.cpp) on gcc 4.4-4.7 with C++11 +
> BOOST_RESULT_OF_USE_DECLTYPE. Is this caused by deficiency of N3276
> decltype support?

I don't know. Maybe Thomas can have a look. I tried to understand the
code for Phoenix lambda and broke my brain. :-P This test also fails
on msvc when BOOST_RESULT_OF_USE_DECLTYPE is defined.

> P.S. What was the main reason for the incompatibility between
> Phoenix and decltype-based result_of? And how did you fix it?

A host of small problems, most of them pretty simple. Here's an example:

struct Fun
{
  typedef void result_type;

  template<typename T>
  void operator()(T & t) const
  {}
};

struct S {};
typedef boost::result_of<Fun(S)>::type should_be_void_t;

The trouble with this is that result_of will create an rvalue of type
S and try to pass that to Fun's operator(). It will fail because
rvalues don't bind to non-const lvalues. But this works fine with TR1
result_of.

For Phoenix, the fix was usually to make the function parameter a
const ref. In other cases, the right fix might be to change the
result_of invocation to: boost::result_of<Fun(S &)>.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

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