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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Followup-To: yes Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada,comp.lang.c++ Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <1110329098.642196@athnrd02> <1110361741.551255@athnrd02> <422edaec$0$26554$9b4e6d93@newsread4.arcor-online.net> <1111464133.508323@athnrd02> <423fe9df$0$11476$9b4e6d93@newsread2.arcor-online.net> <1111521825.653841@athnrd02> <424094b0$0$11481$9b4e6d93@newsread2.arcor-online.net> <1111568404.687226@athnrd02> <1111572591.296439@athnrd02> <1111574207.72969@athnrd02> 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: Thu, 24 Mar 2005 01:58:34 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1111629514 24.149.57.125 (Wed, 23 Mar 2005 17:58:34 PST) NNTP-Posting-Date: Wed, 23 Mar 2005 17:58:34 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:9862 comp.lang.c++:46959 Date: 2005-03-24T01:58:34+00:00 List-Id: Ioannis Vranos writes: > I think an associative container like map fits better to this. What do > you do in Ada if you want to associate product names with prices, in > the style: > > productlist["something"]= 71.2; Ada 2005 comes with a standard container library, very similar to the C++ STL. For example: declare package Map_Types is new Ada.Containers.Indefinite_Ordered_Maps (String, Float); M : Map_Types.Map; begin M.Include (Key => "something", New_Item => 71.2); end; There's also a standard hashed map. > or a name with a number (string with string) in an address book > application for example? > > > namelist["Obry Pascal"]="321-45563"; See above. The element type in this case is String instead of Float. > Also may you tell me if that famous compile-time boundary checking > applies (can be used) to user-defined containers too? I guess the answer is yes, since subtype constraints are inherited from generic actual types. For example, if we have: type My_Float is new Float range 0.0 .. 42.0; and you instantiate the map with My_Float, then you'll get Constraint_Error if you attempt to insert a float value outside the range of the subtype. -Matt