Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-10-02 16:56:57


----- Original Message -----
From: "Howard Hinnant" <hinnant_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, October 02, 2000 5:16 PM
Subject: Re: [boost] Re: auto_array

> Greg Colvin wrote on 10/2/2000 4:26 PM
> >I just tried that, but discovered in testing that it would incorrectly
> >convert from Derived[] to Base[].
>
> Not that there's anything wrong with auto_array_ptr, but you can still do
> it with parametrization on the deleter function. Just consider the
> deleter function to be an allocator, and then mess around with the rebind
> member template such that the one for delete[] doesn't work right.
>
> #include <iostream>
> #include <memory>
>
> using std::auto_ptr;
> using std::_Array;
>
> struct A
> {
> A() {std::cout << "construct A\n";}
> virtual ~A() {std::cout << "destruct A\n";}
> };
>

<snip> Hint: set "always use spaces for indentation" in your wonderful
CodeWarrior IDE ;-)

> Don't try this at home though. You risk getting publicly called an idiot
> by Francis Glassborow. ;-)

An honor I can only aspire to ;-?

> Admittedly, I was not actually using auto_array_ptr, because I needed to
> traffic in uninitialized memory. But it was a very close relative. I
> can easily see that vector is not always a drop-in replacement for
> auto_array_ptr (but admit that it often can be).

For the record, my use was similar to Howard's. Of course an
auto_array_ptr<char> could work for uninitialized memory, couldn't it?

-Dave


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