Boost logo

Boost :

From: AlisdairM (alisdair.meredith_at_[hidden])
Date: 2003-11-28 11:41:03

"Thorsten Ottosen" <nesotto_at_[hidden]> wrote in

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

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


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