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!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: A few questions Date: Tue, 03 Nov 2015 08:26:45 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="2d7699570724a9a82a760842267e2c56"; logging-data="2162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jgLTj8uJ1WaMsXGt1cpCjn4OPTA+HQj4=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:G6fUGJboUiSp4J7/TESdf+4/ips= sha1:lDWtoNGSYSK5IqrneKz0oFCyYhY= Xref: news.eternal-september.org comp.lang.ada:28192 Date: 2015-11-03T08:26:45+00:00 List-Id: "Randy Brukardt" writes: > "Simon Wright" wrote in message >> function Constant_Reference >> (Container : aliased Date_Container; >> Position : Cursor) return Constant_Reference_Type; >> >> returning >> >> type Constant_Reference_Type >> (Element : not null access constant Ada.Calendar.Time) is private >> with >> Implicit_Dereference => Element; > If you *only* need constants, the Constant_Indexing function can be a > normal function (no implicit dereference required). In that case, the > implementation will do the memory management. Note the difference in > wording between 4.1.6(2/3) and 4.1.6(3/3) (there is no requirement on > the return type for Constant_Indexing). Worked a treat! > OTOH, I think GNAT got that wrong somehow when I constructed an ACATS > test to try that (don't recall the details). So it may not work in > your copy of GNAT, most likely it will in a future version. No problem (for the constant case) with GCC 5.1.0 or GNAT GPL 2015.