[vsipl++] proposal: a typed alloc_align()

Mark Mitchell mark at codesourcery.com
Thu Nov 3 19:41:28 UTC 2005


Nathan (Jasper) Myers wrote:

> I'm wrong.  If you provided an op delete(void*, vsip::impl::align&)
> then (5.3.4 para 19) the compiler would generate a call to it if 
> the constructor were to throw.  However, there's no syntax for a 
> delete-expression to call it, and anyway no mechanism to tell (e.g.) 
> std::auto_ptr<>() to use the right op delete overload.

Right, my suggestion was to have:

1. The overloaded placement-new operator for the allocation.

2. The placement-delete operator to handle the exception.

3. An ordinary functon ("vsip::impl::free_aligned") to call to
deallocate the memory.  This would probably be implemented in terms of
the placement-delete operator, or vice versa.

There are other potentially bad aspects of my idea, though.  For
example, for a class type with a destructor, the compiler will allocate
extra storage to record how many entries are in the array; we may not
want that extra storage.  The extra storage comes at the start of the
array, and would mess up the intended alignment of the array elements.

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
(916) 791-8304



More information about the vsipl++ mailing list