STL w/ smart pointers
Phil Bouchard
phil@fornux.com
Tue Jul 22 09:47:00 GMT 2008
Greetings,
I am submitting preliminary patches required for the STL to support smart
pointers as node pointers. The changes aren't too important in contrast to
the benefits we get from this. If STL can support smart pointers thru
"allocator::pointer" then we'll be able acheiving better abstraction and
thus better support for algorithms such as merging, sorting, multi-indexing,
graphing, ... of containers.
These patches are partial and offer a great example on a "std::list<>"
instanciated using a special allocator having "allocator::pointer" as a
smart pointer. Furthermore I have added temporary definitions of
"_List_node_base<_Alloc>::hook()" and "_List_node_base<_Alloc>::unhook()" in
"list.tcc" to complete non-existant ones in libstdc++. Last but not least I
am assuming there is implicit conversions between a "T *" and a
"allocator::pointer" of type "smart_ptr<T>" either with its constructor or
with conversion operators inside the smart pointer.
As a matter of fact, we can find the entire example inside the following
directory:
https://svn.boost.org/svn/boost/sandbox/shifted_ptr/
Where:
- shifted_ptr\boost\shifted_allocator.hpp: example of allocator and smart
pointer having implicit conversions
- shifted_ptr\libs\smart_ptr\example\shifted_ptr_test2.cpp: test file (which
compiles but doesn't run properly yet)
Obviously any help is appreciated having this ported to std::map, stack,
vector, etc. The changes are minimal in regards to the benefits and having
support from Gcc's experts would help tremendously.
Regards,
-Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stl_list.h.patch
Type: application/octet-stream
Size: 11264 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20080722/33389564/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list.tcc.patch
Type: application/octet-stream
Size: 2549 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20080722/33389564/attachment-0001.obj>
More information about the Libstdc++
mailing list