comp.lang.ada
 help / color / mirror / Atom feed
From: jimmaureenrogers@worldnet.att.net (Jim Rogers)
Subject: Re: Specialization
Date: 31 May 2002 07:08:36 -0700
Date: 2002-05-31T14:08:37+00:00	[thread overview]
Message-ID: <82347202.0205310608.2f7d634d@posting.google.com> (raw)
In-Reply-To: ad72e5$e9c$1@ns.felk.cvut.cz

"Sergey Koshcheyev" <serko84@hotmail.com> wrote in message news:<ad72e5$e9c$1@ns.felk.cvut.cz>...
> "Jim Rogers" <jimmaureenrogers@worldnet.att.net> wrote in message
> news:3CF6CF7D.8000704@worldnet.att.net...
> > Baugereau wrote:
> > > Ok so this is the difference of philosophy with STL's vector, which is
>  plain
> > > value-oriented.
> > > What I dislike here is the lack of locality of the elements, and the
>  need to
> > > "new" every time I add an element...
> > > Any comment?
> >
> > The difference is that in C++ you "new" the element before you add
> > it to the vector (in the constructor).
> 
> This is wrong, if you have a vector<BigObject> in C++ STL, then what is
> stored are BigObjects, not pointers to them. There are a few tricks that can
> be used to achieve this ("placement new", and also the fact that it is
> possible to call object destructors manually).

You got me there. My ignorant message assumed you were correct when you claimed
that the C++ STL did not need to allocate nodes in its container classes.

I have since done a little research on the web. I see that the STL container
classes do indeed allocate objects and copy them. This is clearly documented
in http://www.sgi.com/tech/stl/alloc.html 

After reading the above reference I see no significant difference between
the problems you encountered in Ada and the way the C++ STL is currently
implemented (regarding node allocation). Note that the SGI document states
that their allocator uses malloc rather than new. I am not sure this is
a big performance or safety advantage. It may be more flexible than the C++
new operator.

You clearly understand how to use the C++ STL. Have you ever implemented
the C++ STL before? I think you are only now encountering the low level
details which must exist in the C++ STL.

Jim Rogers



  parent reply	other threads:[~2002-05-31 14:08 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             ` Jim Rogers [this message]
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                     ` Specialization Hyman Rosen
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