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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Empty Bounded Containers Date: Fri, 23 May 2014 16:45:33 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1401134684 11432 69.95.181.76 (26 May 2014 20:04:44 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 26 May 2014 20:04:44 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:20036 Date: 2014-05-23T16:45:33-05:00 List-Id: wrote in message news:cfe5082c-9b50-4c5b-afe1-8dd6ea1640b9@googlegroups.com... ... >which is not intuitively what I would assume. For instance, the following >line: > >x : BC.Vector (Capacity => 42) := BC.Empty_Vector; The problem here is using ":=" on bounded containers. Because of the capacity discriminant, it will never work quite right. The whole reason that Assign and Copy were introduced into the Ada 2012 containers is to work around this problem. You want: X : BC.Vector (Capacity => 42) := Copy(BC.Empty_Vector, Capacity => 42); Or: X : BC.Vector (Capacity => 42); BC.Assign (Target => X, Source => BC.Empty_Vector); Ada has no way to avoid discriminant checks in ":=", so there is no possibility of making it work like you would want. Randy.