A
abir
Hi,
In the std containers erase takes a const_iterator.
I have my own container and there const_iterator is a const pointer
to the item.
I want to free the memory for the item on erase (i.e both destroy &
deallocate).
However deallocate function for allocator (and so delete, free etc)
takes a pointer rather than
a const pointer. Is that mean i have to cast it back to a pointer?
I was looking at std::list. There even a const_iterator returns a non
const node pointer (not very sure though).
Also how this works ? does the operator delete automatically cast it
to a non const type ?
const testobj* to = new testobj(1,1);
delete to;
In C, while this works
char* ch = (char*)std::malloc(5);
std::free(ch);
for a const pointer i explicitly need to cast it back like,
const char* ch = (const char*)std::malloc(5);
std::free((char*)ch);//or std::free(void*)ch);
Thanks
abir
In the std containers erase takes a const_iterator.
I have my own container and there const_iterator is a const pointer
to the item.
I want to free the memory for the item on erase (i.e both destroy &
deallocate).
However deallocate function for allocator (and so delete, free etc)
takes a pointer rather than
a const pointer. Is that mean i have to cast it back to a pointer?
I was looking at std::list. There even a const_iterator returns a non
const node pointer (not very sure though).
Also how this works ? does the operator delete automatically cast it
to a non const type ?
const testobj* to = new testobj(1,1);
delete to;
In C, while this works
char* ch = (char*)std::malloc(5);
std::free(ch);
for a const pointer i explicitly need to cast it back like,
const char* ch = (const char*)std::malloc(5);
std::free((char*)ch);//or std::free(void*)ch);
Thanks
abir