
14 Oct
2005
14 Oct
'05
11:27 p.m.
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