From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-17 14:09:32


From: "David Abrahams" <dave_at_[hidden]>
> Hi Peter,
>
> This change broke iterator support in the Boost.Python library:
>
> description:
> Fix for data member support, result_type was R instead of R const &
>
> I know it's not completely uniform, but I think the standard generally has
> result_type being a value, not a reference.

True, but boost::bind doesn't follow this practice. Its result_type is the
exact return type of operator(). In

T const & f();

bind(f);

result_type is "T const &" and not T.

The reason for preserving the exact return type is that if you want to
forward the result one more time:

template<class B> typename B::result_type apply(B b)
{
    return b();
}

apply(bind(f));

changing by-(const-)ref returns into by-value will break if T is
noncopyable/abstract. The theory being that you can always get a cv-stripped
result type from the original but not vice versa.

Of course on deficient compilers you cannot. :-( But this should not affect
the design.

> If you make it a reference I
> have hassles on compilers without partial specialization because I can
only
> strip the reference at runtime.
>
> Was this an important thing to do?

This was a bug, pure and simple. The result_type was documented to be a
const reference to the member type.

We can revert the change for this release if you insist, but earlier or
later this has to be fixed.