Boost logo

Boost :

Subject: Re: [boost] [core] Breaking change to boost::ref in 1.56
From: Peter Dimov (lists_at_[hidden])
Date: 2014-07-14 04:08:01


Andrey Semashev wrote:
> I think Boost.Proto is one of the examples where undesired reference
> recursion happened.

Boost.Proto just uses cref in a generic context, where its argument
sometimes happens to be a reference_wrapper. That's not undesired.

> If not because of performance, conceptually there are no references to
> references in C++, and std::ref attempts to reflect that.

There are references to reference_wrapper though.

> Now that Boost.Proto does reference collapsing, reverting the change will
> break it again (I think).

That's possible, but I don't think so.

I suspect that you don't actually have a motivating example in mind. Given
reference collapsing, how would you take advantage of it? What code have you
written, or will write, that needs it?

Do you realize that the simple use

#include <boost/ref.hpp>

int main()
{
    int x = 0;
    boost::reference_wrapper<int> r = boost::ref( x );

    boost::reference_wrapper< boost::reference_wrapper<int> > r2 =
boost::ref( r );
    boost::reference_wrapper<int> r3 = boost::ref( r );
}

actually works without the overloads? They only serve to break r2.


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