"Peter Dimov" <[EMAIL PROTECTED]> writes:

> It's fairly easy to provide a get_pointer for std::auto_ptr. ;-) 

One that works for regular pointers as well, and works on msvc6? I'd
love to see that!

> It ought to
> be in std:: but a boost:: overload would do as well since the pointer
> version is in boost.
>
> boost/get_pointer.hpp?

Sure, be my guest!

>> 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.

OK.

>> 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?

If you can work out how to write get_pointer, I guess that works.

>> 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->. ;-)

Not sure what you mean. You're free to impose a != 0 requirement for
operator-> of scoped/shared_ptr, but auto_ptr doesn't have such a
requirement on its operator->.

-- 
                       David Abrahams
   [EMAIL PROTECTED] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to