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