From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Move semantics Date: Tue, 20 Sep 2022 17:46:24 +0300 Organization: Tidorum Ltd Message-ID: References: <5b429465-6166-4f33-ad1d-3103e4847efcn@googlegroups.com> <868rmfjnx4.fsf@stephe-leake.org> <87k05znqpk.fsf@nightsong.com> <0b04f763-fa89-4b34-ad52-eb9d57d80d8cn@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net KfDJ8JVIae5yzc2xK+LPUAkzy+0uhJdJQwh0/ilybeWC9e5SGi Cancel-Lock: sha1:iZs5meyF0vyWZIky7oNdSZ/CT4o= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Content-Language: en-US In-Reply-To: <0b04f763-fa89-4b34-ad52-eb9d57d80d8cn@googlegroups.com> Xref: reader01.eternal-september.org comp.lang.ada:64371 List-Id: On 2022-09-20 14:44, AdaMagica wrote: > Paul Rubin schrieb am Montag, 19. September 2022 um 20:50:50 UTC+2: >> I think it refers to the C++ notion. >> https://en.cppreference.com/w/cpp/utility/move > > What I do not understand: Why should the move operation be less expensive than a copy? > As I see it: First you have to do a copy, then delete the source. The standard Ada containers have Move operations. Containers are of course often implemented with indirection, where the container object contains accesses to the data held in the container, so a Move operation only has to copy the access values from the source to the target, and does not need to copy the data. The access values in the source are then nulled, making the source container empty. This is often less expensive than copying the data. Eg. for Vectors, the Ada RM says "Move should not copy elements, and should minimize copying of internal data structures." For the bounded Ada containers, which are not meant to use indirection, while there are Move operations the RM says that the implementation advice "to minimize copying" does not apply.