I know that, new operator will call the constructor of class.
But how it\'s happening, what is ground level techniques used for this.
Here is how I imagine it:
T* the_new_operator(args)
{
void* memory = operator new(sizeof(T));
T* object;
try
{
object = new(memory) T(args); // (*)
}
catch (...)
{
operator delete(memory);
throw;
}
return object;
}
(*) Technically, it's not really calling placement-new, but as long as you don't overload that, the mental model works fine :)