220 28076 <57C6F249.1030601@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: Wed, 31 Aug 2016 11:05:45 -0400
Lines: 56
Approved: news@gmane.org
Message-ID: <57C6F249.1030601@gmail.com>
References: <ec2e95cc-3ef0-435b-aaf9-13e982c4583e@isocpp.org>
 <CANh8DEm-3RG1u99c6dUqSgthiVR_wE6FOfzHGbKuMqZBDptcOg@mail.gmail.com>
 <db0b8dd4-5cd9-4d4d-b7a8-95d6ab15ad8c@isocpp.org>
 <4387866d-169e-44a8-a858-d9aa96d54680@isocpp.org>
 <CAE7XuEXEV=xKW_g-1h1MFbg-3Fya83xkcoqGePvPbBPMTXPamA@mail.gmail.com>
 <85dfd0dc-bf1a-4fa8-81f5-2b36e8f6465c@isocpp.org>
 <57C48794.6020105@gmail.com>
 <a90060ce-0316-4c11-b123-9326cf91b16d@isocpp.org>
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 1472655962 7252 195.159.176.226 (31 Aug 2016 15:06:02 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 31 Aug 2016 15:06:02 +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
Original-X-From: std-proposals+bncBC37LBFWUIFBBTHETO7AKGQEHCAV4GI@isocpp.org Wed Aug 31 17:05:53 2016
Return-path: <std-proposals+bncBC37LBFWUIFBBTHETO7AKGQEHCAV4GI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f197.google.com ([209.85.217.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC37LBFWUIFBBTHETO7AKGQEHCAV4GI@isocpp.org>)
	id 1bf75J-0000gx-BG
	for gclcip-std-proposals@m.gmane.org; Wed, 31 Aug 2016 17:05:49 +0200
Original-Received: by mail-ua0-f197.google.com with SMTP id m60sf108556325uam.3
        for <gclcip-std-proposals@m.gmane.org>; Wed, 31 Aug 2016 08:05:50 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:reply-to:message-id:date:user-agent
         :mime-version:in-reply-to:x-original-sender
         :x-original-authentication-results:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=RfgB1FHRTImXjWVc79dIA/xwEf+Xl7nkivwBQxlwIIU=;
        b=KhxYBRADeNoYUzpdvvPv2BDlCrbGWIL2Fhan0gMgolubOBWJ9Y7jZqqr2ewYh9RZSt
         f5SYYG0bKAK0kKFFs4MZwCKEky5Y9xvdjppsyD51upJ6nWn6e+HiyWRka2Qb07h+OYqN
         2zY5AEA7BkVjDmxu0sP2IM2KcptqF3L0BpXCkcVNO0re6F3uztJqV4Urto9MAWCfjy3Y
         wca7H+uOKEbsU8ECyAKz/FBjAlhjVFNLRRVwkWWwPQPslGHTbYIKbNklUTU7UUltS6L/
         oKlpGHQZosUlrS8h4Bsx+FtxsLlzRacFN4TY/9VRZa1Jl8JMveLBu5CfOWzOLifgyCEz
         a+Zw==
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:from:reply-to:message-id
         :date:user-agent:mime-version:in-reply-to:x-original-sender
         :x-original-authentication-results:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=RfgB1FHRTImXjWVc79dIA/xwEf+Xl7nkivwBQxlwIIU=;
        b=cKTxHfO8NZXjCBHJ+hsOIw8BFWB9tiXKK+Ed+82b+5237aoE/tqshKoQNGKcN/TvxR
         rYId4bpSeW5t/bQyrnFJkqggekQT6nickX2eCOCfC/0Y1E4LR0KHbTj3qLWkCNmqz7Ez
         vKxTiWRFFNq1eilNxPKb6bvdvCCYsmk3udKwcSReWTBUWdWHNOqJUNiXpN5UFumDZ5Xr
         wFhqp+vYJmwu2FFJm0q5YeCVrSH2cEh5fv1TpD8usUBcHSMli9aEW5w0EKnJDdnTXYnA
         h7LG86qr3fnLSrfw16k6VxCjsH3QnP1GIqaURLi5R+9fwUem35Q25wtDSWvbnc4xLOZ8
         QCtA==
X-Gm-Message-State: AE9vXwODcZikJgK2VEWLlx3e6Z0v48iz8hX6d+Yvf3C3r7t0oQ7ExZoh/oSatWuexP9A0A==
X-Received: by 10.157.2.202 with SMTP id 68mr7447179otl.28.1472655949182;
        Wed, 31 Aug 2016 08:05:49 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.13.112 with SMTP id 103ls4091830oti.11.gmail; Wed, 31 Aug
 2016 08:05:48 -0700 (PDT)
X-Received: by 10.55.95.2 with SMTP id t2mr2376493qkb.144.1472655947967;
        Wed, 31 Aug 2016 08:05:47 -0700 (PDT)
Original-Received: from mail-qk0-x235.google.com (mail-qk0-x235.google.com. [2607:f8b0:400d:c09::235])
        by mx.google.com with ESMTPS id 49si258157qtm.41.2016.08.31.08.05.47
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 31 Aug 2016 08:05:47 -0700 (PDT)
Received-SPF: pass (google.com: domain of mwoehlke.floss@gmail.com designates 2607:f8b0:400d:c09::235 as permitted sender) client-ip=2607:f8b0:400d:c09::235;
Original-Received: by mail-qk0-x235.google.com with SMTP id l2so54152006qkf.3
        for <std-proposals@isocpp.org>; Wed, 31 Aug 2016 08:05:47 -0700 (PDT)
X-Received: by 10.55.203.213 with SMTP id u82mr11135913qkl.255.1472655947504;
        Wed, 31 Aug 2016 08:05:47 -0700 (PDT)
Original-Received: from [192.168.1.173] (tripoint.kitware.com. [66.194.253.20])
        by smtp.googlemail.com with ESMTPSA id w10sm169369qtc.28.2016.08.31.08.05.46
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 31 Aug 2016 08:05:46 -0700 (PDT)
X-Enigmail-Draft-Status: N1110
In-Reply-To: <a90060ce-0316-4c11-b123-9326cf91b16d@isocpp.org>
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::235 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:28076
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28076>

On 2016-08-29 16:38, Nicol Bolas wrote:
> On Monday, August 29, 2016 at 3:05:59 PM UTC-4, Matthew Woehlke wrote:
>> On 2016-08-29 14:46, Nicol Bolas wrote: 
>>> This problem is fundamentally identical to the temporary lifetime 
>>> extension problem. Namely, that this works: 
>>>
>>> const auto &str = std::string(...); 
>>> //use str 
>>>
>>> While this does not: 
>>>
>>> const auto &str = std::string(...).c_str(); 
>>> //use str 
>>
>> I think having explicit temporary types might help here: 
>>
>>   std::string::c_str() -> char const* register; // declaration 
>>
>>   // error: taking reference of register-qualified type. 
>>   const auto &str = std::string(...).c_str(); 
>>
>> Obviously, it is too late to change std::string this way, but it would 
>> help us write better API's going forward.
> 
> How would that solve the problem? How does the compiler connect the return 
> value's lifetime to the lifetime of one of the function parameters?* Which* 
> parameter should it connect it to? All of them?

....yes? I'm not sure you're asking the right question; `register` here
means that the value becomes invalid "almost immediately", i.e. as soon
as the inputs that led to its "creation" change, the return value is
invalidated. (So, yes, I want to say "all of them" is the correct answer.)

> And why would you use `register` of all things for that?

It grew out of the original idea of `register` being used to annotate
something that is "more ephemeral than usual". (And also, because it's
available.) Nothing says we couldn't use something else.

> P0066 provided a more comprehensive solution to lifetime analysis. And it 
> was ultimately rejected 
> <https://botondballo.wordpress.com/2015/11/09/trip-report-c-standards-meeting-in-kona-october-2015/>
> .

Ah, well, that's not reassuring. Oh, well. I'm not sure I agree that the
problem is 'too niche', but...

-- 
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/57C6F249.1030601%40gmail.com.

.
