design doc on alternative pointer support
Phil Bouchard
posts@fornux.com
Wed Jul 23 07:12:00 GMT 2008
"Bob Walters" <bob.s.walters@gmail.com> wrote in message
news:8C8DB82B-29D9-448C-8261-672FF30D19CC@gmail.com...
>
> A copy of the pdf explaining the design of the alternative pointer
> capability is available at:
>
> http://stlshm.sourceforge.net/alt_pointers_in_stl_containers.pdf
Hi,
I am facing the same problem as yours but I am coming from a very different
path hence I have a different perspective. Early this week I wrote a patch
we can find herein attached to this email. My changes are very similar to
yours, I am propagating the allocator all the way up to the node but I saw
some issues we will have if we use a different smart pointer such as mine:
shifted_ptr or any other as a matter of fact like: shared_ptr.
Firstly I would recommend adding to the allocator a new typedef called
"iterator" that will define the type used inside container iterators. This
will remove unwelcomed overhead for intensive iterator usage.
Secondly some specilized code will need to be added. In the case of
conversions between raw pointers and smart pointers this is not a problem
because we just need adding explicit &* because this cannot be done
implicitly. But in the case of _M_erase() and _M_clear() member functions
we will have problems because smart pointers already handle the deletion of
their object. We'll need some sort of specialized functors over there.
Last but not least, _M_impl node cannot be pointed to by smart pointers
because smart pointers expect objects living on the heap. This is not
always the case here because it is a member of the containers and the latter
will likely be instanciated on the stack. The easiest solution here is to
allocate _M_impl on the heap using the allocator, just like all other nodes.
-Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stl_list.h.patch
Type: application/octet-stream
Size: 11525 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20080723/02e8a42f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list.tcc.patch
Type: application/octet-stream
Size: 2553 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20080723/02e8a42f/attachment-0001.obj>
More information about the Libstdc++
mailing list