comp.lang.ada
 help / color / mirror / Atom feed
From: Hyman Rosen <hyrosen@mail.com>
Subject: Re: Specialization
Date: Fri, 31 May 2002 17:25:27 -0400
Date: 2002-05-31T17:25:27-04:00	[thread overview]
Message-ID: <3CF7EA47.20909@mail.com> (raw)
In-Reply-To: ad8kvi$12g0$1@ns.felk.cvut.cz

Sergey Koshcheyev wrote:
 > As for ordinary new, it does return you a pointer to a
> fully initialized object, doesn't it?

As does placement new. It's one of those silly overloaded
C++isms again. There are two news. One is 'new-expression',
and it is this that returns a pointer to a fully initialized
object. The other is 'operator new' which returns a pointer
to allocated but uninitialized storage. The 'new-expression'
first calls 'operator new' to allocate storage, then builds
the initialized object(s) in that storage.

The key is that 'operator new' is actually an overloaded
family of functions. One of those overloads takes an extra
pointer parameter and simply returns it, and that is the
form generally known as 'placement new'. That is, ordinary
'operator new' calls malloc (essentially) to get storage
for the allocated object, while placement 'operator new'
simply hands back what you give it, namely previously
allocated storage.

The syntax of a 'new-expression' includes the ability to
specify additional parameters for 'operator new', which
allows it to use placement 'operator new'.




  reply	other threads:[~2002-05-31 21:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-30 12:39 Specialization Baugereau
2002-05-30 17:09 ` Specialization Ted Dennison
2002-05-30 17:29   ` Specialization Baugereau
2002-05-30 19:20     ` Specialization Stephen Leake
2002-05-30 19:48       ` Specialization Baugereau
2002-05-31  1:18         ` Specialization Jim Rogers
2002-05-31  5:41           ` Specialization Sergey Koshcheyev
2002-05-31 11:36             ` Specialization Baugereau
2002-05-31 14:08             ` Specialization Jim Rogers
2002-05-31 16:45               ` Specialization Hyman Rosen
2002-05-31 17:05               ` Specialization Sergey Koshcheyev
2002-05-31 17:40                 ` Specialization Hyman Rosen
2002-05-31 20:04                   ` Specialization Sergey Koshcheyev
2002-05-31 21:25                     ` Hyman Rosen [this message]
2002-05-31 13:27         ` Specialization Stephen Leake
2002-05-31 19:46           ` Specialization Simon Wright
2002-06-01 15:30             ` Specialization Stephen Leake
2002-05-31 19:44   ` Specialization Simon Wright
2002-06-01 15:25     ` Specialization Stephen Leake
2002-06-01 17:12       ` Specialization Simon Wright
2002-06-01 19:50         ` Specialization Stephen Leake
2002-05-30 17:46 ` Specialization Toshitaka Kumano
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox