ptr_container issue/question regarding polymorphic types

It is my understanding that ptr_containers allow and support pointers to polymorphic types. But, the following does not appear to be possible: class Animal { }; class Cow: public Animal { }; ptr_vector<Cow> cows; ptr_vector<Animal> animals; ... // Add in some cows to the cows container ... // Transfer all cows to the animal container // Error: transfer() is not a class member function template // it expects the "from" container to be of the same types of pointers animals.transfer(animals.end(),cows.begin(),cows.end(),cows); Thanks, Mike

On 12/12/05, Michael Goldshteyn <mgoldshteyn@comcast.net> wrote:
// Transfer all cows to the animal container // Error: transfer() is not a class member function template // it expects the "from" container to be of the same types of pointers animals.transfer(animals.end(),cows.begin(),cows.end(),cows);
According to the docs: http://boost.org/libs/ptr_container/doc/ptr_sequence_adapter.html#pointer-co... "You cannot use transfer() to move elements between two different types of
containers. This is to avoid problems with different allocators. The requirement might be weakened in the future."
-- Caleb Epstein caleb dot epstein at gmail dot com
participants (2)
-
Caleb Epstein
-
Michael Goldshteyn