I have a custom allocator for a vector, but I would rather not have it in the code everywhere. So I thought to cast it to a normal vector
vector<Complex> * createVector(size_t nfft)
{
vector<Complex,fftalloc<Complex > > * data = new vector<Complex,fftalloc<Complex > >(nfft);
return reinterpret_cast<vector<Complex> *>(data);
}
my allocator/deallocator functions print out if they are called:
pointer allocate (size_type num, const void* = 0) {
// print message and allocate memory with global new
ALLOCDEBUG << "allocate " << num << " element(s)"
...
}
void deallocate (pointer p, size_type num) {
// print message and deallocate memory with global delete
ALLOCDEBUG << "deallocate " << num << " element(s)"
...
}
But a test with
{
vector<complex<double> > * v;
v = fft.createVector(16);
v->push_back(1);
delete v;
}
prints out only the allocate function.
Is it possible to cast without loosing the deallocator?