allocator question, regarding pointer types

Matt Austern austern@apple.com
Fri Feb 13 04:59:00 GMT 2004


On Feb 11, 2004, at 5:53 PM, Benjamin Kosnik wrote:

>
>> However, in the stl code I've looked at (specifically, the stl headers
>> that came with gcc 3.2), that typedef is not used, but instead I see:
>>
>>    struct _List_node_base
>>  {
>>    _List_node_base* _M_next;
>>    _List_node_base* _M_prev;
>>  };
>
> There are big changes between 3.2/3.3 and 3.4 sources WRT allocators.
>
> The 3.4 sources are more in line with the standard.
>
>> This seems (from my naive reading of std::allocator articles) to break
>> the allocator design.  i.e. I thought that if I wanted to create an
>> allocator that can magically return a pointer of size 1 byte, that the
>> typedef inside the allocator ( typedef char pointer; ) would be used
>> in the container for the pointer type.
>
> Please provide sources to what you are trying to do.

Without seeing the source, I can guess: the idea is to write an
allocator where MyAllocator<T>::pointer is something other
than T*.  For example, it might be a MySmartPointer<T>, or it
might be T __attribute((weirdmachinemode))__*.

This isn't a completely unreasonable goal.  In principle allocators
are supposed to support this.

In practice, supporting this would require some fairly major
surgery on our container classes.  It isn't rocket science, but it
also isn't completely trivial.

			--Matt



More information about the Libstdc++ mailing list