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: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Why is the destructor called multiple times after I declare an object? Date: Thu, 14 Jan 2016 10:04:36 +0100 Organization: A noiseless patient Spider Message-ID: References: <293c58ac-4ebd-488a-abcc-b6e88811eec8@googlegroups.com> <871t9ogevj.fsf@theworld.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 14 Jan 2016 09:01:58 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="45bffd6a911624777cad79aac3181090"; logging-data="1474"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+O5BFKurw2v04lygcF8sOQ" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: Cancel-Lock: sha1:0VeGlZFKDcbXdGMrP5NpUVu+Lkg= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:29123 Date: 2016-01-14T10:04:36+01:00 List-Id: Le 13/01/2016 21:09, Dmitry A. Kazakov a écrit : >> OK, let's state it differently. The called function builds its result >> "somewhere". That "somewhere" is what will be used by the caller as the >> variable being initialized. > > A non-limited result is built "somewhere", just the same. I think > in-place must be a definite place, not just "somewhere". In the non-limited case, copying is allowed (although not required), so there is no issue. What I mean is that it can work the other way round from your mental model: you think of the caller allocating the result space, and the function using that space; but it can be the function that choses where to build the result, and then the caller using that space for the object. It may not be the usual stack model, but that's irrelevant (we already know that a secondary stack may be used in some cases). >> It is perfectly OK if the function starts building the result in >> "somewhere_1", then decides to switch to "somewhere_2", as long as the >> eventual "somewhere" is what is used by the caller, /without copy/. > > "Without copy" requires a definition too. IMO, it must mean that no type > operations are called otherwise than on the final result (function > arguments do not count). For example, Initialize must be called strictly > once. "Without copy" means that the value constructed and returned by the function should not be moved to a different memory location. What else? -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr