allocator question, regarding pointer types

Trey Jackson tjackson@ichips.intel.com
Wed Feb 11 00:10:00 GMT 2004


All,

I've recently learned about std::allocators.  Here are the two most applicable:

   http://www.cuj.com/documents/s=8000/cujcexp1812austern/
   http://www.langer.camelot.de/Articles/C++Report/Allocators/Allocators.html

I noticed the use of type

   allocator::pointer

and supposedly containers should be using that type to refer to memory
that was allocated by the allocator.  sweet!

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;
  };


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 help me figure this out...


Thanks,

TJ

ps. Yes, I'll be reading the mailing list, so personal email is not required.

-- 
Trey Jackson
tjackson@ichips.intel.com

Paul's Law: You can't fall off the floor.



More information about the Libstdc++ mailing list