Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-08 14:58:42

----- Original Message -----
From: "Howard Hinnant" <hinnant_at_[hidden]>

> Oh, I think I get it now! <slapping forehead>. The client initializes
> the memory at his leisure before asking vector to take ownership of
> Doesn't that make vector overkill? Why not just give the memory to a
> smart pointer that will use delete[]? Then you wouldn't have to worry
> about exception safety while you're still in the initialization phase.

Depending on T, it's not safe to delete[] this thing if not all elements
are initialized. Also, such memory held by a smart pointer doesn't have
lots of the nice dynamic qualities of vector<>.

> Essentially you've got a chunk of memory that's going to change types
> (well, change owners) mid way through its life. From raw pointer (or
> smart pointer) to vector. Is there sufficient motivation for this
> mid-life ownership transfer? Would that really help solve more
> than it creates? It may be simpler to just create your own container
> that tolerates indeterminant scalars.

No container can portably tolerate indeterminate scalars, unless it's
write-only ;-(.


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