Boost logo

Boost Users :

Subject: Re: [Boost-users] "weak" binding to member?
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2011-09-14 00:21:01


On 9/13/2011 4:35 AM, Igor R wrote:
> Well, I think I've figured out how to solve your problem. Since
> Boost.Bind invokes your functor through ->* operator, you just need to
> define your own get_pointer() function that returns an adapter that
> defines ->* operator, which would do what you want.

Interesting.
I had thought about defining an adaptor that provided operator->, but that would not work
with the semantics I want to duplicate. It would be perfect if you intended to throw an
exception if the weak ptr was dead.

But using ->* gives control over the actual call, so the code can be skipped.

I suppose that the inner workings of bind must use operator->* at some point (how else can
it work?) this would be portable, even though it's not mentioned in the documentation or
the standard.

I already wrote an adaptor that is analogous to mem_fn, which is probably about the same
complexity as what you show, and doesn't court portability issues. But thank you very
much for the idea; I think it is easy to forget about operator->* when looking for solutions.

—John


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net