From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,927ae253da8bb547 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-31 04:34:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!proxad.net!wanadoo.fr!not-for-mail From: "Baugereau" Newsgroups: comp.lang.ada Subject: Re: Specialization Date: Fri, 31 May 2002 13:36:28 +0200 Organization: Wanadoo, l'internet avec France Telecom Message-ID: References: <4519e058.0205300909.5bfb317d@posting.google.com> <3CF6CF7D.8000704@worldnet.att.net> Reply-To: "Baugereau" NNTP-Posting-Host: afontenayssb-103-1-4-21.abo.wanadoo.fr X-Trace: wanadoo.fr 1022844873 23707 80.11.133.21 (31 May 2002 11:34:33 GMT) X-Complaints-To: abuse@wanadoo.fr NNTP-Posting-Date: 31 May 2002 11:34:33 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Xref: archiver1.google.com comp.lang.ada:25070 Date: 2002-05-31T11:34:33+00:00 List-Id: > > 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 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.