220 28015 <57C4509E.4050107@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Matthew Woehlke <mwoehlke.floss@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Specifier to cause the destructor to be called at
 last use instead of end of scope
Date: Mon, 29 Aug 2016 11:11:26 -0400
Lines: 35
Approved: news@gmane.org
Message-ID: <57C4509E.4050107@gmail.com>
References: <ec2e95cc-3ef0-435b-aaf9-13e982c4583e@isocpp.org>
 <CANh8DEm-3RG1u99c6dUqSgthiVR_wE6FOfzHGbKuMqZBDptcOg@mail.gmail.com>
 <db0b8dd4-5cd9-4d4d-b7a8-95d6ab15ad8c@isocpp.org>
 <CANh8DEkMPP-Wpc_DFxzHLpngYu=_8SmrArpBU8ARxUVjyN2_8A@mail.gmail.com>
 <CAE7XuEUZjb7M3wXdv4b+Su=t8MmTkAj51dDQDw3qiPMjqZtfRw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: blaine.gmane.org 1472483495 12658 195.159.176.226 (29 Aug 2016 15:11:35 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 29 Aug 2016 15:11:35 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.1.0
To: std-proposals@isocpp.org, calabrese@x.team
Original-X-From: std-proposals+bncBC37LBFWUIFBBINBSG7AKGQEYDZBTYY@isocpp.org Mon Aug 29 17:11:30 2016
Return-path: <std-proposals+bncBC37LBFWUIFBBINBSG7AKGQEYDZBTYY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f198.google.com ([209.85.217.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC37LBFWUIFBBINBSG7AKGQEYDZBTYY@isocpp.org>)
	id 1beODg-0002it-Nj
	for gclcip-std-proposals@m.gmane.org; Mon, 29 Aug 2016 17:11:28 +0200
Original-Received: by mail-ua0-f198.google.com with SMTP id 30sf86975483uab.1
        for <gclcip-std-proposals@m.gmane.org>; Mon, 29 Aug 2016 08:11:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:newsgroups:from:message-id:date:user-agent
         :mime-version:in-reply-to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=p5ZJ+zU48zpZqQ/Ctle+dxqqfz6mZ2KVT1Mm2lfuDow=;
        b=d3QF3+eUczc+ffGm8R5MA/gj984pWxNM129uz03H581pJtGgWwVZBWNMP/Myz/wpQ3
         8elIhcq+MHQksrx3P7QXA5hMnc2z48dxx6NNwdl06GneW1T6ssRuTQ3izc1fAGsv+KK8
         1v2/Ng4SfUcdJ0nvWOZDaEQ/Nz12ecx3oh1InrnZi+pGbv/HiiS/sOpAfWYz7BPU69zT
         dmfWZXVrfd7eUAdHBpFiR5pVAXW6GlcEDiP6OwIo+PSgezn5A9TGNMsbJM4gzl+dWfWV
         9FTCPykEDQv8LvTsr+bv6wKRR5I/Ur7Z+dUY1lziBETWSb4q+jP0vnf/plQ73k/ZfG1Q
         tCsg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:subject:to:references:newsgroups:from:message-id
         :date:user-agent:mime-version:in-reply-to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=p5ZJ+zU48zpZqQ/Ctle+dxqqfz6mZ2KVT1Mm2lfuDow=;
        b=Af9/kTXCkztrpD/zgXUK9oc1wKIhTIFs4lKswaOeIZfkf7bS9FPzsqoJGqxGmKB6Xa
         X2F+yMflUB9irYXHn4F/Hj06Qn262D/k4yQUYpHX3SWyJXVVLgt+Au5OKwtwOm8iZ2JX
         eJrnYLWNrB4FRKtQyw5/Y+5i/ox9Kti5mZ8vqqOMy5h81PDLmJseqCMphqQNUKpSbOji
         +C86HNx3U4QWC0N/3UnFUHHaRdMPwZxbYGYV2LYM2gzR/+evlI7SOwm2TcHPzFjrUZgU
         /SGV1yT/4/vbrWTHLoHfOaD+Kwp7wKV0blTO28Bf35Z9HPNzpnoNHpfNRQaQtORMZNLI
         wVXg==
X-Gm-Message-State: AE9vXwNBteTwsvV2gJUIEip26nyYsif4pgKIVpSyZoggG21ykDtxtyfsWpmmB8JDSCOAaQ==
X-Received: by 10.176.3.233 with SMTP id 96mr6517417uau.4.1472483489543;
        Mon, 29 Aug 2016 08:11:29 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.14.162 with SMTP id 31ls7242031otj.25.gmail; Mon, 29 Aug
 2016 08:11:28 -0700 (PDT)
X-Received: by 10.37.91.86 with SMTP id p83mr4453573ybb.178.1472483488830;
        Mon, 29 Aug 2016 08:11:28 -0700 (PDT)
Original-Received: from mail-qk0-x232.google.com (mail-qk0-x232.google.com. [2607:f8b0:400d:c09::232])
        by mx.google.com with ESMTPS id i10si23586875qta.6.2016.08.29.08.11.28
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 29 Aug 2016 08:11:28 -0700 (PDT)
Received-SPF: pass (google.com: domain of mwoehlke.floss@gmail.com designates 2607:f8b0:400d:c09::232 as permitted sender) client-ip=2607:f8b0:400d:c09::232;
Original-Received: by mail-qk0-x232.google.com with SMTP id l2so140872579qkf.3
        for <std-proposals@isocpp.org>; Mon, 29 Aug 2016 08:11:28 -0700 (PDT)
X-Received: by 10.55.26.154 with SMTP id l26mr18340179qkh.224.1472483488630;
        Mon, 29 Aug 2016 08:11:28 -0700 (PDT)
Original-Received: from [192.168.1.173] (tripoint.kitware.com. [66.194.253.20])
        by smtp.googlemail.com with ESMTPSA id p139sm7966389qke.45.2016.08.29.08.11.27
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 29 Aug 2016 08:11:28 -0700 (PDT)
Original-Newsgroups: gmane.comp.lang.c++.isocpp.proposals
X-Enigmail-Draft-Status: N1110
In-Reply-To: <CAE7XuEUZjb7M3wXdv4b+Su=t8MmTkAj51dDQDw3qiPMjqZtfRw@mail.gmail.com>
X-Original-Sender: mwoehlke.floss@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 mwoehlke.floss@gmail.com designates 2607:f8b0:400d:c09::232 as permitted
 sender) smtp.mailfrom=mwoehlke.floss@gmail.com;       dmarc=pass (p=NONE
 dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:28015
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28015>

On 2016-08-26 17:23, Nicolas Capens wrote:
> On Wed, Aug 24, 2016 at 6:00 PM, Matt Calabrese wrote:
>> I'm sorry if I sound overly negative here, but the problems of this are
>> already well understood. For any kind of early destruction in a language
>> like C++, users would need to be explicit, and that's not bad in this case.
>> I genuinely do believe that something similar to this is worthwhile, but
>> your particular approach is unrealistic (I think specifically that
>> destructive-move would solve a lot of problems with the language and
>> library as it is today).
> 
> I'd like to avoid getting sidetracked too much, but remind me again what
> destructive-move would solve that can't be done by overloading the
> assignment operator?

Destructive move a.k.a. relocation solves the problem of having to
maintain invariants in an object that is about to be destroyed anyway.
Consider for example your large matrix, with the invariant that its
storage is always allocated. In order to move construct an instance, you
must first allocate memory, then exchange the new memory with the
instance being moved from, so that the moved-from instance remains in a
valid state.

With relocation, you *know* that the old instance is being destroyed
anyway, so you can just take possession of its memory instead without
any new allocations.

-- 
Matthew

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/57C4509E.4050107%40gmail.com.

.
