This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: allocator question, regarding pointer types


Benjamin wrote:
> 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.

Is it possible to get the source w/out going through CVS?
I didn't see anything on the mirror that was 3.4...

If not, I'll try to get a copy from CVS, thanks.


> Please provide sources to what you are trying to do.

Basically, I was telling someone about how cool allocators were, and
that we could use an allocator that returned 32-bit pointers even in a
64-bit environment.

e.g. (I may have the this done wrong, but it's the idea)

,----------------
| template <class T> class my_heap_allocator
| {
| public:
|   typedef T                 value_type;
|   typedef 32_bit_type       pointer;
|   typedef const 32_bit_type const_pointer;
|   typedef value_type&       reference;
|   typedef const value_type& const_reference;
|   ...
| };
|
| // implement a heap for type T, one that returns
| // a "pointer" that's just a 32-bit index into the heap
| // well, it actually converts the 'void *' into a valid 32-bit index
`----------------


With the 3.3.2 sources for libstdc++, this was not possible.

I took a look at (what I think is the gcc4.0 branch)

http://sources.redhat.com/cgi-bin/cvsweb.cgi/gcc/libstdc%2b%2b-v3/include/bits/stl_list.h?rev=1.34&content-type=text/x-cvsweb-markup&cvsroot=gcc&only_with_tag=gcc-3_4-branch

And it looks like in that version of the stl_list.h, the node pointers
created by the allocator are still referenced through the type

    _List_node_base*

where I would expect something like

   typedef allocator::rebind<_List_node_base>::other nodeAllocator;
   nodeAllocator::pointer _M_next;
   nodeAllocator::pointer _M_prev;


but this is what I find:
,----------------
| struct _List_node_base
|   {
|     _List_node_base* _M_next;   ///< Self-explanatory
|     _List_node_base* _M_prev;   ///< Self-explanatory
| ... 
`----------------



Granted, libstdc++ is still way beyond my grasp, but I hope/think that
my example explains what I was expecting...  



TJ
-- 
Trey Jackson
tjackson@ichips.intel.com

Flick a stick.  Drain the rain.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]