ptr_vector is copy constructible and copy assignable. How can it deep copy the underlying objects when it doesn’t know their concrete types?
ptr_vector is copy constructible and copy assignable. How can it deep copy the underlying
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
boost::ptr_vectorcontainer has an optional template parameter,CloneAllocator, that defines the cloning policy. The default allocator is theheap_clone_allocator, which simply invokes the copy constructor to clone an object.The Clone Allocator is used as a way to add a layer of indirection around the cloning. For example, it allows you to provide a custom allocator that correctly handles cloning of a noncopyable type.
You can find more information in the Boost Pointer Containers Library documentation, which explains the Clonable and Clone Allocator concepts.