
From: Anthony Williams <anthony_w.geo@yahoo.com>
"Fernando Cacciola" <fernando_cacciola@hotmail.com> writes:
// (2) Anthony's proposal: o.reset(rb); // still some room for doubts?
How about
o.replace_with(rb);
I don't think that's any better and it is more verbose.
does that suggest rebinding? I was imagining that reset (or replace_with)
I can just as easily infer assignment as rebinding. Jason Hise's suggestion of rebind() would be quite explicit and could be optimized to just do assignment for builtin types.
would always rebind/replace the contained element, rather than assign to it. Then it would also work with my non-assignable types.
Yes, an interface for non-assignable types that doesn't requiring parameterizing optional would be good. IOW, o.rebind(rb) rather than o = optional<T&>(rb).
* we could provide a means of capturing a value into an optional:
std::pair<Foo, Bar> do_stuff(); boost::optional<Foo> foo; boost::optional<Bar> bar;
tie(rebinder(foo),rebinder(bar))=do_stuff();
s/rebinder/rebind/ That looks nice. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;