Is there any way to initialize value of member field of a class from it's overloaded new operator? I can set values of object in operator new, but after it returns my pre-initialized object, class constructor overrides all uninitialized values (at least, in debug compilation).
What I'm trying to do: allocator that uses vector of buckets of my objects, where newly created objects fill buckets one by one. Each bucket stores amount of filled slots and index of next slot that would be filled, allocator increases that amount and deleter decreases it. When amount reaches zero, it moves bucket to the end of vector of buckets, so when allocator fills currently filling bucket it either reuses that emptied bucket (and moves it into begin of vector) or creates and adds a new one. But for deleter to know which bucket's amount to decrease, it needs a pointer to the bucket where this object was placed (otherwise, I'd need to search each bucket in vector to find object being deleted, or map object pointers to buckets).
So, I'm trying to write current bucket pointer into my objects itself from allocator. But constructor overwrites it with nullptr.