Boost logo

Boost :

From: Maxim Yegorushkin (e-maxim_at_[hidden])
Date: 2004-09-22 07:27:16

Ben Hutchings <ben.hutchings_at_[hidden]> wrote:


>> But I think there might be another solution. The standard states in
>> that arrays of char's allocated with new expression are
>> always properly aligned for types whose size is no greater than the
>> size of the array. Does allocator<char>::allocate() have the same
>> requirement? I could not find it in my copy of the standard.
> The default allocator's allocate() member function uses
> ::operator new(std::size_t) so any specialisation could be used to
> allocate memory aligned for any type.


> However, the requirements for
> allocators in general (table 32 in subclause 20.1.5) say only that
> "[m]emory is allocated for n objects of type T" by the allocate()
> function.

So, that means that there is no requirement and thus it is not guarantied
that any custom_allocator<char> returns a pointer properly aligned for any
type, right?

Maxim Yegorushkin

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