Boost logo

Boost :

Subject: Re: [boost] [core] Breaking change to boost::ref in 1.56
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-07-13 06:16:26

On Sunday 13 July 2014 12:48:30 Peter Dimov wrote:
> Andrey Semashev wrote:
> > Perhaps Eric could provide more context on why Boost.Proto needs recursive
> > reference wrappers? Frankly, the requirement looks strange to me.
> Generic code that does
> boost::reference_wrapper<T> r = boost::ref( t );
> is broken when t is a reference_wrapper.

Ok, but I was also interested in why this is needed by Boost.Proto. I.e.
whether a reference to a reference to a reference... is the intended behavior
of the library and whether it's actually desired to collapse the recursion.

I understand that the library doesn't do that currently and we might need to
revert the change to boost::ref temporarily to fix it for 1.56, but the long
term plan might be to actually fix Boost.Proto. We might declare the old (non-
collapsing) behavior deprecated for 1.56 in the release notes and provide some
wrap_reference<T> trait to make the above code work:

  typename boost::wrap_reference<T>::type r = boost::ref(t);

The trait would do a non-collapsing wrapping for 1.56 and collapse references
for future releases.

> > I'm not strongly opposed to reverting, but the change looks justified
> > enough to me. Allowing dangling reference wrappers is surely not the
> > correct behavior.
> Dangling reference wrappers are prevented by a separate and independent
> change
> 378a
> that is (I think) not affected by the removal of the collapsing overloads.

Ok, good. I take it that the motivating example:


should not compile then?

Boost list run by bdawes at, gregod at, cpdaniel at, john at