This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Nonstandard allocator::pointer in containers
- From: Phil Endecott <phil_kqzdh_endecott at chezphil dot org>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 23 May 2005 16:28:06 +0100
- Subject: Nonstandard allocator::pointer in containers
Dear libstdc++ Experts,
I'm writing an application that uses shared memory to communicate
between processes. I'd like to be able to store standard containers in
this shared memory, but since it can be mapped at different addresses in
different processes I need to use offsets rather than pointers. I seem
to have most of this working, but I'm held up by the fact that the
standard container implementations explicitly use pointers internally,
rather than the allocator<T>::pointer type which I have defined as
offset<T>.
I've asked about this on comp.lang.c++ (e.g. here:
http://groups-beta.google.com/group/comp.lang.c++/browse_frm/thread/2c24ad7a7a5cce65/051e738e0f1a8808?hl=en#051e738e0f1a8808
and am told that the standard only requires containers to work with
allocators that define pointer as T*. However, other libraries seem to
be more generous in what they allow: Dinkumware certainly supports this,
and it looks to me as if the newly-open-source Roguewave library does too.
I'm right at the limits of my understanding of C++ here, and I've no
idea if there are serious downsides to this or whether it's just a case
of doing a search-and-replace of T* by _Alloc::pointer. But I thought
I'd ask here and see what you say. The alternative seems to be to write
my own container class, which is realy not an appealing thought. (Or
maybe I can just paste in the Roguewave one?)
Thanks in advance for any suggestions.
--Phil.
p.s. this is for Anyterm - http://chezphil.org/anyterm/ - could be of
interest to any of you with remote access problems.