|
Boost : |
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-07-01 14:57:40
On Tue, Jul 1, 2008 at 8:32 PM, David Abrahams <dave_at_[hidden]> wrote:
> Giovanni Piero Deretta wrote:
>
>> I still do not see how can you 'fix' BOOST_TYPEOF to deduce const
>> references correctly.
>> Without that, you can't implement result_of with boost typeof.
>
> As written elsewhere, treating a const rvalue as though it were a const
> lvalue should almost never cause a serious problem. It wouldn't be
> perfect, but it would work in a vast majority of cases.
Good point, it is possible to always deduce T& references correctly
and collapase const T& to plain T.
I was trying to come up with something a program that might break
while working correctly with TR1 result_of, but the only thing that
came to my mind is something like this, which is not a strong reason
not to breaking compatibility:
let 'first' be a result_of compatible function object that behaves
like fusion::at_c<0>()
typedef boost::tuple<int> tuple_t;
tuple_t x(0);
boost::result_of<filrst(tuple_t const&)>::type r = first(x);
assert(&r == &boost::get<0>(x));
The assert will fail if result_of uses BOOST_TYPEOF.
Just be safe, a result_of that uses typeof might have a different name.
-- gpd
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk