Boost logo

Glas :

Re: [glas] unallocated fill

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2005-10-05 09:56:55

Neal Becker wrote:

> For PODs and many others this may be OK. I believe the best approach is
> 1) Don't initialize by default, but
> 2) Allow initialization as a user-controlled option.
> It is not sufficient to use template specialization to handle PODs specially.
> For example, std::complex in particularly should be able to bypass
> initialization if the user desires.

Done (at least in the dense_vector). For all built-in types *and*
std::complex, no constructors will be called explicitly after the call
to allocate. Same goes for the calls to the destructor before the
deallocate. I've documented also the meta-function 'need_construct'
which should return what the behaviour should be for whatever element-type.

Nevertheless I would be interested in knowing if compiler-writers agree
with the approach taken. Because IIUC, after the call to 'allocate' of
the allocator we /should/ explicitly call the constructor for each
element in the array, right?