|
Boost Users : |
From: Matthew Bray (mat_at_[hidden])
Date: 2007-03-20 09:37:16
I have a problem with the current ptr_sequence interface, according to
the documentation point #7 at this location:
http://www.boost.org/libs/ptr_container/doc/examples.html#transferring-ownership-of-pointers-between-different-pointer-containers
it should be possible to write something such as this
ptr_list<X> list; ptr_vector<X> vec;
list.transfer( list.begin(), vec.begin(), vec );
vec.transfer( vec.end(), list.begin(), list.end(), list );
i.e. given a U<T> and a V<T> I should be able to perform transfer
operations in either direction.
However given a suitable X this code fails to compile on VC++ 8 as well
as GCC 3.4. Indeed any attempt to transfer between different
ptr_sequence types (e.g. ptr_deque<X> to ptr_vector<X>) fails to
compile. Looking at the implementation of ptr_sequence it appears easy
to see why this is the case. However my question is is the documentation
incorrect or is the current code incorrect?
Right now if I wish to create containers of objects and then transfer
ownership to others I'm forced to use the same container type throughout
(i.e. the transfer functions provide no benefit at all if I have to
choose the wrong container for the job), either that or write awkward
transferal code when it appears the simple transfer function should do
the job.
Could someone please explain the situation regarding the transfer
functions and documentation at this time?
Thanks, Mat.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net