Topic: Naming of 'placement new


Author: "John Hickin" <hickin@nortel.ca>
Date: 1998/02/19
Raw View
tamlin@algonet.Sweden (Mike Nordell) wrote:

>Since many people tends to think of 'placement new' as
> operator new (void*, size_t);
>but really any variation of the 'normal new' is called placement,
>maybe we should try to come up with at common term?
>*I* think that the *placement* new is the one cited above, but in that
>case, what should we call all the other forms? Overloaded? Extended?

Suppose we see code of the form

 new(aRegion) X; // allocate a new X from Region aRegion

According to the current definition in the standard this is a placement
new. I believe that the definition of placement new that you have in
mind would exclude my new(size_t,Region&) implentation.

Next, have a look at:

 void* operator new( size_t sz , const char* f , int l )
 {
   HANDLE h1 = CreateFile( f,...);
   HANDLE h2 = CreateFileMapping( h1,...);
   ...
   return MapViewOfFile( h2, ... , ); // uses sz and l
 }

Isn't that a placement new too?



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: tamlin@algonet.Sweden (Mike Nordell)
Date: 1998/02/19
Raw View
An ongoing discussion in c.l.c++.m triggered me to write the
following.

Since many people tends to think of 'placement new' as
 operator new (void*, size_t);
but really any variation of the 'normal new' is called placement,
maybe we should try to come up with at common term?
*I* think that the *placement* new is the one cited above, but in that
case, what should we call all the other forms? Overloaded? Extended?
It could mean the difference between understanding and not
understanding each other when discussing any other form of 'new' than
the 'normal' placement form.

&Mike

Change 'Sweden' to 'se' to reply by mail.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "John D. Hickin" <hickin@CAM.ORG>
Date: 1998/02/19
Raw View
Mike Nordell wrote:

> Since many people tends to think of 'placement new' as
>         operator new (void*, size_t);
> but really any variation of the 'normal new' is called placement,
> maybe we should try to come up with at common term?

I find that many of my coded placements new that don't conform to
the new(size_t,void*) signature do, in fact, place objects in specified
memory, as in

 new(aRegion) X; // new X placed in block allocated from aRegion.
   // new(size_t,Region&)

This should be a placement new in the spirit of the definition that you
might like to see; if you concede me this point why not embrace the
fully abstract definition? It exists in the standard today and dates
back to 1990 (The Annotated C++ Reference Manual, Ellis & Stroustrup)
at least, and possibly earlier.

Regards,  John.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]