How boost: ptr_vector deeply copies base objects?

ptr_vector is a copy construct and assignable copy. How can he deeply copy base objects when he does not know their specific types?

+6
c ++
source share
1 answer

The boost::ptr_vector has an optional CloneAllocator template parameter that defines the cloning policy. The default heap_clone_allocator is heap_clone_allocator , which simply calls the copy constructor to clone the object.

Clone Allocator is used as a way to add a layer of indirection around cloning. For example, it allows you to create a custom dispenser that correctly handles cloning of a non-copyable type.

For more information, see the Boost Pointer Containers library documentation , which explains the concepts of Clonable and Clone Allocator.

+8
source share

All Articles