Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2001-04-05 15:31:35


On Thursday, April 5, 2001, at 03:52 PM, Gary Powell wrote:

> I'd be glad to have a "new and improved" auto_ptr but we should give
> it a
> new name. Meantime I'm just trying for a auto_array_ptr. And since that
> doesn't exist in std, I'm open to any and all "improvements"

At the risk of getting repetitive, my favorite name for auto_array_ptr
is:

template<class X>
class auto_ptr<X[]>
;

But I imagine that people using a compiler that doesn't support partial
specialization wouldn't be happy with that. Nevertheless, if there is
interest, I would be happy to help modify the boost::auto_ptr to do
this. For those of you who may have missed my previous posts on this
subject below is a short description...

> In that light, are you suggesting that auto_array_ptr not use
> auto_ptr_ref?

I haven't looked at the details of auto_array_ptr, but based on my
experience with this type of class I would think that auto_array_ptr
still needs auto_ptr_ref. But the template parameter of auto_ptr_ref
must be constrained to be the same as the template parameter of
auto_ptr. Thus there is no need for the member template methods in
auto_ptr to be member templates; they should be ordinary member
methods. Since there are already ordinary member methods with the
appropriate signature, the member template methods can simply be removed.

On auto_ptr<X[]>:
---------------------

A newbie once asked on comp.lang.c++ if the following would work:

auto_ptr<char[]> ap(new char[3]);

Obviously it doesn't, it should cause a compile time error. But I
thought it might be neat if it did work. After all, if this is how a
newbie would expect it to work, then that is a fair argument for
intuitiveness. It is not too difficult to create a partial
specialization of auto_ptr on X[] that acts like auto_array_ptr. In
fact, it is really nothing more than renaming auto_array_ptr<X> to
auto_ptr<X[]>. Any arguments for or against auto_ptr<X[]> vs
auto_array_ptr should focus on the merits of the name of the class. I
believe that the functionality is the same either way.

-Howard


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