Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-10-21 15:30:22


From: Anthony Williams <anthony_w.geo_at_[hidden]>
> "Fernando Cacciola" <fernando_cacciola_at_[hidden]> 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_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk