Today I saw a strange initialization of a pointer. It looks like this:
struct A
{
void* data;
int bufLen;
...
}
void fun(A* a, int* result)
{
SomeClass* b = new (a->data) SomeClass();
}
It's completely fine, it does compile, it does work, but I don't know why.
I'd like to know what's going on with the initialization of the variable b
.
Is it a cast? Is it a copy of the variable a->data
in a new memory slot?