I have the following case:
boost::ptr_vector<float> vec;
float* array = new float[4]();
vec.push_back(array);
// Add some more elements to vec..
How can I ensure that if I leave this scope and vec will be destroyed the ptr_vector’s destructor calls delete[] and not delete on every element of vec. I don’t understand how it should work, because the template parameter float will be the same for float* and float[4].
You could specify the
CloneAllocatortemplate parameter ofptr_vectorto be something other than the default,heap_clone_allocator. There is no way to make an instance of the actual classboost::ptr_vector<float>usedelete[]instead ofdelete.