I met with some codes as below.
char *buffer = new char[sizeof(PoolThread) * numThreads];
m_threads = reinterpret_cast<PoolThread*>(buffer);
for (int i = 0; i < numThreads; i++)
{
new (buffer)PoolThread(*this);
buffer += sizeof(PoolThread);
}
I guess the new
here is for initializing the empty memory space pointed to by m_threads
to a real object (of PoolThread
class)
I've googled, but only found infos of usage of new
like this:
pointer = new somthing[number];
I hope more info of the usage of new
in my upper code example. And does this usage comes from c++ standard?