comp.lang.ada
 help / color / mirror / Atom feed
From: "Baugereau" <baugereau@ifrance.kom>
Subject: Re: Specialization
Date: Fri, 31 May 2002 13:36:28 +0200
Date: 2002-05-31T11:34:33+00:00	[thread overview]
Message-ID: <ad7n49$n4r$1@wanadoo.fr> (raw)
In-Reply-To: ad72e5$e9c$1@ns.felk.cvut.cz


> > 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).

Exactly. This is what I was talking about :)
I want contiguity (is this English, I'm not sure :) ) of all the elements in
the container.

>
> > If you were to dynamically allocate all your objects in Ada, just as
> > you do in C++, then the container would not need to perform any of the
> > dynamic allocation. You could simply add references to the objects
> > just like you do in C++.
>
> When using STL containers, you can add a local object into the container,
> for example, and it will be properly copied.
>
> > You will also find that Ada scoping rules are much more strict than C++
> > scoping rules. This can influence the way you design your container
> > package.
>
> The scoping rules are not the problem, I think. You can copy the objects,
if
> needed. To imitate C++ in this respect, you just need some way (possibly,
a
> hack) to manually Initialize and Finalize the inserted objects, and ensure
> that the compiler doesn't also try to do that. Maybe playing with
> Storage_Pools a little will lead to a solution. Or maybe there is a more
> Ada-like way, I don't know.

I'll check the storage pools in the ARM. Thanks.





  reply	other threads:[~2002-05-31 11:36 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             ` Baugereau [this message]
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                     ` 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