|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2005-10-14 18:27:24
AlisdairM wrote:
>
> int a = 13;
> int &b = a;
> int c = 42;
>
> optional< int & > d = b;
> d = c;
>
<snip>
>
> For the curious, the current answer is option 3 - d rebinds a reference
> to c.
Huh. IANAOU* but this seems surprising to me. I would expect this not to
rebind the reference. Had I wanted that behavior, I would have used an
int*, or else I would have done something like:
optional< tr1::reference_wrapper<int> > d = b;
or some such. Has interoperability with tr1::reference_wrapper<> been
pursued as a means to give boost::optional<> reference rebinding
semantics which are ... optional? ;-)
* IANAOU == I am not an optional user
-- Eric Niebler Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk