I have the following class:
struct globalAllocated
{
void operator delete(void*p)
{
static HANDLE heap= GetHeap();
::HeapFree(heap, 0, p);
}
}
warning C4640: 'heap' : construction of local static object is not thread-safe
I thought about using some synchronization with mutex but it seems costly.
Making the heap a private member won't work because the operator delete override must be static, so heap must be private- but if I declare it as a static class member, there is no where for me to initialize it.
What's the best solution?