Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-11-30 09:55:12


From: "David Abrahams" <dave_at_[hidden]>
>
> Hi,
>
> I'm wondering whether the get_pointer function used by mem_fn et
> al. is really justified. Since you can't invoke a member function on a
> null pointer anyway, why not simply use &*p for this purpose?

The original reason for using get_pointer in mem_fn is that mem_fn does not
require get_pointer(p) to return &*p, or p.get(), or a raw pointer. It only
expects an object with operator->* defined. Another reason is that supplying
a get_pointer() for an existing type is (potentially) less intrusive than
enabling the &*p syntax.

On the other hand... the ((*p).*f)(...) form would work with most smart
pointers and iterators, so it might be worth exploring.


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