|
Boost : |
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-11-28 22:18:30
"AlisdairM" <alisdair.meredith_at_[hidden]> wrote in message
news:Xns9441A9B88A91alisdairmeredithukre_at_80.91.224.252...
> "Thorsten Ottosen" <nesotto_at_[hidden]> wrote in
> news:00d601c3b5c7$0dd83b60$73071ed3_at_nesottolap:
>
>
> >> These are two different things.
>
> > clearly, but which is better?
>
> I guess that depends on whether you need to specify array size at runtime.
>
>
> > ok, but if auto_array supports transfer of ownership, how can the
> > receiver tell the size of the array?
>
> Because they type of the auto_ptr specializtion includes the type it is
> instantiated with. In the case of boost array, the size of the array is
> also part of the type.
>
> In other words the following will not compile due to incompatible types.
> (namespaces omitted for readable example)
>
> auto_ptr< array<int, 1> > one( new array<int, 1> );
> auto_ptr< array<int, 2> > two( one );
you misunderstood. How can I safely use the current auto_array (not the
auto_ptr< array<1,int > >) when
there is no way of telling the size of thecontained array. With scoped_ptr
it's kind of ok, since the size is
known locally, but with ownership transfer, you're fu**** :-)
> > can you explain?
>
> I just liked the neat way of using auto_ptr with arrays, and not having to
> worry about calling delete[] I struck me as cute <g>
specializze auto_ptr<T>::~auto_ptr() and others for arrays ?
br
Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk