Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-11-30 10:56:20

From: "David Abrahams" <dave_at_[hidden]>
> "Peter Dimov" <pdimov_at_[hidden]> writes:
> > On the other hand... the ((*p).*f)(...) form would work with most smart
> > pointers and iterators, so it might be worth exploring.
> Yes, and in particular it would work with std::auto_ptr, which I know
> is not a candidate for bind because it's not CopyConstructible, but it
> is important for other reasons.

It's fairly easy to provide a get_pointer for std::auto_ptr. ;-) It ought to
be in std:: but a boost:: overload would do as well since the pointer
version is in boost.


> Maybe the thing to do is to provide a generalized get_pointer template
> which does &*p.

This doesn't allow p to be NULL; get_pointer has no such requirement.

> And now, on to a tougher problem:
> What's the generic form to use for checking whether a Dereferenceable
> type is NULL?

get_pointer(p) != 0?

> The only forms which work for std::auto_ptr is:
> !p.get()
> !p.operator->()
> I'd use the second one for all class types, but STLPort's debug mode
> asserts instead of returning 0. It's a nonconforming but IMHO very
> reasonable extension :(.

It won't work for scoped/shared_ptr either, and I haven't forgot the != 0
requirement in operator->. ;-)

Boost list run by bdawes at, gregod at, cpdaniel at, john at