Re: Is this a new syntax
Alf P. Steinbach wrote:
{
(void*) new (h) Class_Name(xip, virobj, type, true);
}
The only thing you really know is that that code is most likely full
of bugs.
Sorry, that last assumes that it's written by an ordinary programmer.
It /could/ be that it's written by an expert.
But if not, then it's probably chock full of bugs.
I wonder a bit about the differentiation between ordinary and expert
programmer. Most probably there are not that many people around, that
use this syntax without the adequate knowledge. In fact I have never
seen any buggy implementation with this syntax.
At some locations it is really useful. E.g. STL containers can reserve
space for new elements without calling the standard constructor
immediately. As far as I remember std::vector works this way to deal
with the logical size versus the allocation size.
Or I have implemented a simple, highly efficient, Java like, immutable
string class, that takes only the memory footprint of char* per instance
and the string value plus two ints header per different string value
(reference counted).
So, the syntax is only rarely needed. But if so, it is very important.
It is something like a back door for special purposes to call the
constructor directly. Calling a destructor explicitly is not less
dangerous and looks quite normal.
Marcel