I found this snippet
void* operator new(size_t nbytes)
{
if (nbytes == 0)
nbytes = 1; // so all alloc's get a distinct address
void* ans = malloc(nbytes + 4); // overallocate by 4 bytes
*(Pool**)ans = NULL; // use NULL in the global new
return (char*)ans + 4; // don't let users see the Pool*
}
here https://isocpp.org/wiki/faq/dtors
I spent over an hour now trying t understand what *(Pool**)ans = NULL; does.
ans is a void pointer, so I would assume it is cast to a Pool pointer and the pool is set to 0. Not he pointer but the pool itself, because of the third * on the left. But Pool has no operator= defined.
pointer** in a declaration is apparently a pointer to a pointer... but in this context this makes no sense to me, as ans is a single pointer.