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

Nathan (Jasper) Myers ncm at codesourcery.com
Thu Nov 3 18:48:36 UTC 2005


On Thu, Nov 03, 2005 at 07:58:00AM -0800, Mark Mitchell wrote:
> Jules Bergmann wrote:
> 
> >     float* foo = alloc_align<float>(align, elem);
> 
> Note that you could spell this like:
> 
>   new(vsip::impl::align(16)) float[elem]

Be careful.  Conventionally, storage obtained via op new is 
released via op delete.  The compiler enforces that: if you said 
"new (vsip::impl::align (16)) vsip::Fft<>", for example, and the
Fft<> constructor threw an exception, the implicit code generated
by the compiler would call ::op delete itself.

As a library, we can't replace ::op delete ourselves; that choice
is reserved to the main program.

This inflexibility is an unfortunate legacy of early C++, although 
to this day I don't know how it might have been done better.
Probably any such improvement would involve templates.

Nathan Myers
ncm



More information about the vsipl++ mailing list