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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,97a4ff0c3103bbb6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: Matthew Heaney@MHEANEYIBMT43 Newsgroups: comp.lang.ada Subject: Re: Deallocating list of polymorphic objects? References: <1164930027.758923.119740@h54g2000cwb.googlegroups.com> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 01 Dec 2006 03:52:44 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.pas.earthlink.net 1164945164 24.149.57.125 (Thu, 30 Nov 2006 19:52:44 PST) NNTP-Posting-Date: Thu, 30 Nov 2006 19:52:44 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news2.google.com comp.lang.ada:7766 Date: 2006-12-01T03:52:44+00:00 List-Id: "Michael Rohan" writes: > I would like to construct a list of polymorphic objects that, > as part of the list's finalization, deallocates the objects on > the list. Basically, I have a vector of pointers to Object'Class. The easiest way to do that is using the indefinite form: with Ada.Containers.Indefinite_Vectors; package Object_Vectors is new Ada.Containers.Indefinite_Vectors (Object'Class); As others have pointed out, the Ada run-time properly handles deallocation of objects having a class-wide type, so there's nothing special you need to do.