220 36724 <00d91d4c-4ee7-4dbd-a547-3dd844f5685d@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: mihailnajdenov@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Static analysis and the future of C++
Date: Sat, 20 Jan 2018 08:36:08 -0800 (PST)
Lines: 748
Approved: news@gmane.org
Message-ID: <00d91d4c-4ee7-4dbd-a547-3dd844f5685d@isocpp.org>
References: <0087c1a4-0b36-40ca-8d43-5bfaf0af62ca@isocpp.org>
 <a395ffbf-fc53-4288-b1ca-f559e1703eac@isocpp.org> <88864914-82a8-4a8b-bda7-cffd38379edf@isocpp.org>
 <4fa792ec-1f51-4357-a65a-2ce3c10c60c0@isocpp.org>
 <CALvx3hYQHFXi5eRrcdCGEqWj-n4w4NKYDpRx4G_U16i+2VS5nQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2493_1727009190.1516466168923"
X-Trace: blaine.gmane.org 1516466062 5456 195.159.176.226 (20 Jan 2018 16:34:22 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 20 Jan 2018 16:34:22 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCUJ3A7GRAPRB6W7RXJQKGQEUGBOKSI@isocpp.org Sat Jan 20 17:34:18 2018
Return-path: <std-proposals+bncBCUJ3A7GRAPRB6W7RXJQKGQEUGBOKSI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f199.google.com ([209.85.217.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUJ3A7GRAPRB6W7RXJQKGQEUGBOKSI@isocpp.org>)
	id 1ecw5n-0000Yu-KB
	for gclcip-std-proposals@m.gmane.org; Sat, 20 Jan 2018 17:34:08 +0100
Original-Received: by mail-ua0-f199.google.com with SMTP id g47sf3374543uad.14
        for <gclcip-std-proposals@m.gmane.org>; Sat, 20 Jan 2018 08:36:12 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=r9vD+NIl//5eX0TsFwBU2pzljJNhd0QLXR0cnMWfFuo=;
        b=qwuV8mtYgrnx3CzhG+9qlCBuc2eRC896c60x+3zBMue2dD4rkiORAtOm8RBJ4QFNVc
         HSg3COIrKZd2Z+n9MCXtVePW6OOr9jl3nGGaB6nNEx6zuT57vERZaOHqVB8lhuQxwbSu
         FoflRtviz9a+dvjUJA/dU6odcq1PMQ7okg+xAGpnmlzWfDlE3CKQeIn4HABuHRwya3sV
         1+cfMl0ug9fGUo4B5SKQ0ddSbAlIwezM0hib74wUrvmdRnz50yGxgtJCMpMfR8bHa6XK
         bPWqTWBkqbrAxjlOoMNXdPoUHS2NBZmUEe06TW4zwvW71CC9KOx++cnhrpSad8b0Fu0W
         k76g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=r9vD+NIl//5eX0TsFwBU2pzljJNhd0QLXR0cnMWfFuo=;
        b=GyRNIc3bKPKzi46xg2bL7JHgYJupPzmzmpu2gVPYFdht5VdlKJBMk+qO6Pgwt8HIyu
         bmGF0LSZYtEkpTQQv8XqqZsfKG1fSn3UzaoV79Utqq3U1UR4f/6zLQqflG9ZUAEUeiXs
         79AmrH2z7eFtfrZxQti1Tw12y3jPP6uFNNDn/Pk4xDQoy8UCEyQ2IUI//ND3MkE1ro/5
         CHYg5ffJDEmeqwx4AJnzHCABZGOeYsxikHlBy8UvFONwxCX4MnCF0MGn61vFKvy1NoVF
         +hmBbg591+9QpRaN47ouWPK9SKwygtTn+ya6wYoHIT6e8gcyu6m1rZEHz0Tur8klWBta
         QAWg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=r9vD+NIl//5eX0TsFwBU2pzljJNhd0QLXR0cnMWfFuo=;
        b=nx/U32By8y5vsk4kqTULAkj7mnb8dnZpmNX3TxNhw+D1g4cpa5T+ToxvnsZ8PdFNic
         vsF6cpacpuRu6TG9afGYgljidT4Q8jFhzcAnedOnwOrBVbwFSXdxuKntpx6oq00c7BdU
         dHeG9QU+2bqXKfVFDUwE99DVjnftdLTp5phDeKBRUUseTmiX+IGiHK26D77KF7Ijw+ls
         4EaBiAF/JtJNt+2hduyZ0JY3Re6Ja2IMSEfEVza2Fd4xH/ulupmefBUwbOoEJJrw3zlX
         xQ6O2Gi7SmxE3LePYh3zQu4Ztle+i+RZ0TxDXL9iDhcycuJOcXkQ0nIJ61ZfLO8gUfTk
         kU/A==
X-Gm-Message-State: AKwxytfmF0xP1JYWXUFRQoK0Pzc3L3sApYwg5jP/yMtAx1hb2Rr6ZwhA
	2mRochZtqU8SpfFg5ve6y6HF4g==
X-Google-Smtp-Source: AH8x226Ua+6deZwWXJY+mwB//twE8M4ZXcGgGeEIhkLCZlUhop8kipsVrAztyMxFzPj60xMOqs1ICg==
X-Received: by 10.31.233.193 with SMTP id g184mr978275vkh.17.1516466171820;
        Sat, 20 Jan 2018 08:36:11 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.176.14.17 with SMTP id g17ls1155314uak.14.gmail; Sat, 20 Jan
 2018 08:36:10 -0800 (PST)
X-Received: by 10.31.178.206 with SMTP id b197mr196399vkf.11.1516466169643;
        Sat, 20 Jan 2018 08:36:09 -0800 (PST)
In-Reply-To: <CALvx3hYQHFXi5eRrcdCGEqWj-n4w4NKYDpRx4G_U16i+2VS5nQ@mail.gmail.com>
X-Original-Sender: MihailNajdenov@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:36724
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36724>

------=_Part_2493_1727009190.1516466168923
Content-Type: multipart/alternative; 
	boundary="----=_Part_2494_1021269791.1516466168924"

------=_Part_2494_1021269791.1516466168924
Content-Type: text/plain; charset="UTF-8"



On Saturday, January 20, 2018 at 4:54:53 PM UTC+2, Richard Hodges wrote:
>
> > Copies of observer_ptr still monitor the same address, but with a 
> different scope - their dtor, release or reset.
>
> It would be nice if this were enough.
>
> consider
>
> auto& exec = some_async_executor();
> auto up = std::make_unique<Foo>();
>
> auto p = observer_ptr(up.get());
> exec.post([p] { something_with(*p); });    // A
> exec.post([up = std::move(up)] { something_with(*up); }); // B
> exec.post([p] { something_with(*p); });   // C
>
> Assume that B's lambda invocation may or may not complete before C's lambda 
> invocation.
>
> I can't see how this could be statically analysed. It's an undetectable 
> logic error, since as far as the compiler is concerned, it has no way of 
> knowing that C's p may outlive B's up.
>
> Note that at the point of the construction of each of the 3 lambdas, the 
> pointers captured are all valid (except in the crossing case where there is 
> a context switch after the post at B).
>


In any case this does heap allocation for the views (the lambdas, inside 
the exec class) and presumably threading after that. Both are impossible to 
track. 


For both however we have nice tools - shared and week ptr. 

Which is ironic - the complex code is more safe then the trivial one. Yes 
you could use the heavyweight tools for simple tasks, but that is not zero 
overhead any more. 

Static analysis is the tool to help us with the common, simple, yet 
(terribly) unsafe tasks, still keeping zero overhead.


Having said that, there are scenarios where tracking will not give accurate 
prediction - the destruction might, for instance, depend upon some real 
time state.
That is the reason, these cannot be errors, only warnings.
The compiler should, however, be able to see all paths leading to 
destruction even the once behind real time check/uncertainty and warn that 
"it *might *dangle" or that "no one can be certain, even you!".

In your example, the compiler should warn it can't predict the observer - 
has no visibility over its lifetime and/or the observed destruction is 
behind real time uncertainty. 
He might even suggest alternative like share/weak ptr, because *observe_ptr 
was not the right tool in the first place!* The compiler will only reaffirm 
that fact. 

 

>
>
>
> On 20 January 2018 at 12:12, <mihailn...@gmail.com <javascript:>> wrote:
>
>>
>>
>> On Friday, January 19, 2018 at 10:19:40 PM UTC+2, Nicol Bolas wrote:
>>>
>>> On Friday, January 19, 2018 at 7:30:52 AM UTC-5, mihailn...@gmail.com 
>>> wrote:
>>>>
>>>> Can we "just" define special behavior of observer_ptr (in 
>>>> debug/analyze mode) and solve all cases of lifetime monitoring (under the 
>>>> said limitations) - from smart pointers to function_view?
>>>>
>>>
>>> That's not "behavior" of the type. There is no actual code in 
>>> `observer_ptr` that does anything you're talking about. It's simply a 
>>> compiler or tool that sees you using this particular type and starts 
>>> looking at things because of it.
>>>
>>
>> If the constructor and reset of observer_ptr are decorated with 
>> something like [[debug:observe_destruction]] the behavior of observer_ptr 
>> will be enforced by the compiler. 
>>
>> The behavior, use and definition of observer_ptr are not changed.  
>>  
>>
>>>
>>> It should also be noted that this still doesn't handle perfect 
>>> forwarding. Not unless it is the caller of the function who wraps the 
>>> parameter in an `observer_ptr`.
>>>
>>
>> class A_view
>> {
>>   A_view(const A* pa) : _p(pa) {}
>>   A_view(const A& a) : _p(&a) {}
>>   A_view(A&& a) : _p(&a) {}
>>
>>   observer_ptr<const A> _p;
>> }; 
>>
>> observer_ptr will monitor addressof(*_p) for ~A() call. The scope of 
>> monitoring is ~observer_ptr() or release() call.
>>
>> Copies of observer_ptr still monitor the same address, but with a 
>> different scope - their dtor, release or reset.
>>
>>
>> That is a major difference from lifetime extension - we can have 
>> many-to-one mapping without any semantic or implementation problems. Lifetime 
>> extension does not allow copies of a view/ref to extend with the lifetime 
>> of the object.
>> We are also not limited to initialization only - the monitoring can 
>> (re)start at the call of reset() instead on constructor call only. Lifetime 
>> extension deals with initialization exclusively. 
>>
>>
>> How can perfect forwarding interfere in all this? 
>>
>>
>> template<typename T, typename ...Args>
>> auto init(Args&&... arg)
>> {
>>   return T(std::forward<Args>(arg)...); //< observer_ptr starts 
>> monitoring &arg
>> }
>>
>> int main()
>> { 
>>   auto v = init<A_view>(A{}); //< both A_view and A allocated. A_view 
>> usable before the ';' when ~A is called
>> }
>>
>> If copy elision does not kick-in nothing changes - copy is safe and 
>> defined, lifetime of A is the same.
>>
>> If we pass arguments and create A in init() instead ( return  T(A(std::forward<Args>(arg)...)); 
>> ), then the observer_ptr is still created with a valid address, 
>> however, after we return will not be able to use A_view in any way, 
>> including before the ';'. 
>>
>> If both there is no elision and A is created when initializing T inside 
>> init, then the returned view can be created from a dangling view. 
>> We could allow views from dangling views to be created, however no dtor 
>> will be monitored and all uses of the view will be illegal until 
>> destroyed/reset/release-ed. 
>> We could also issue a warning on coping from dangling view without 
>> problem.
>>
>>
>>
>>
>>  
>>
>> -- 
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4fa792ec-1f51-4357-a65a-2ce3c10c60c0%40isocpp.org 
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4fa792ec-1f51-4357-a65a-2ce3c10c60c0%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
>
>

-- 
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/00d91d4c-4ee7-4dbd-a547-3dd844f5685d%40isocpp.org.

------=_Part_2494_1021269791.1516466168924
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Saturday, January 20, 2018 at 4:54:53 PM UTC+2,=
 Richard Hodges wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">&gt;=C2=A0<span style=3D"font-size:13px">Copies of=C2=A0</span><sp=
an style=3D"font-size:13px;background-color:transparent;margin:0px;padding:=
0px;border:0px rgb(34,34,34)">observer_ptr still monitor the same address, =
but with a different scope - their dtor, release or reset.</span><div><span=
 style=3D"font-size:13px;background-color:transparent;margin:0px;padding:0p=
x;border:0px rgb(34,34,34)"><br></span></div><div><span style=3D"font-size:=
13px;background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,=
34,34)">It would be nice if this were enough.</span></div><div><span style=
=3D"font-size:13px;background-color:transparent;margin:0px;padding:0px;bord=
er:0px rgb(34,34,34)"><br></span></div><div><span style=3D"font-size:13px;b=
ackground-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)=
">consider</span></div><div><span style=3D"font-size:13px;background-color:=
transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><br></span></d=
iv><div><span style=3D"font-size:13px;background-color:transparent;margin:0=
px;padding:0px;border:0px rgb(34,34,34)"><font face=3D"monospace, monospace=
">auto&amp; exec =3D some_async_executor();</font></span></div><div><span s=
tyle=3D"font-size:13px;background-color:transparent;margin:0px;padding:0px;=
border:0px rgb(34,34,34)"><font face=3D"monospace, monospace">auto up =3D s=
td::make_unique&lt;Foo&gt;();</font></span></div><div><span style=3D"font-s=
ize:13px;background-color:transparent;margin:0px;padding:0px;border:0px rgb=
(34,34,34)"><font face=3D"monospace, monospace"><br></font></span></div><di=
v><span style=3D"font-size:13px;background-color:transparent;margin:0px;pad=
ding:0px;border:0px rgb(34,34,34)"><font face=3D"monospace, monospace">auto=
 p =3D observer_ptr(up.get());</font></span></div><div><div><span style=3D"=
font-size:13px;background-color:transparent;margin:0px;padding:0px;border:0=
px rgb(34,34,34)"><font face=3D"monospace, monospace">exec.post([p] { somet=
hing_with(*p); });=C2=A0 =C2=A0 // A</font></span></div></div><div><span st=
yle=3D"background-color:transparent;margin:0px;padding:0px;border:0px rgb(3=
4,34,34)"><div style=3D"font-size:small"><span style=3D"font-size:13px;back=
ground-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><=
font face=3D"monospace, monospace">exec.post([up =3D std::move(up)] { somet=
hing_with(*up); }); // B</font></span></div></span><div><span style=3D"back=
ground-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><=
span style=3D"background-color:transparent;margin:0px;padding:0px;border:0p=
x rgb(34,34,34)"><div style=3D"font-size:small"><span style=3D"font-size:13=
px;background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34=
,34)"><font face=3D"monospace, monospace">exec.post([p] { something_with(*p=
); });=C2=A0 =C2=A0// C</font></span></div><div style=3D"font-size:small"><=
span style=3D"font-size:13px;background-color:transparent;margin:0px;paddin=
g:0px;border:0px rgb(34,34,34)"><br></span></div><div>Assume that B&#39;s l=
ambda invocation may or may not complete before C&#39;s=C2=A0<span style=3D=
"background-color:transparent">lambda invocation</span><span style=3D"backg=
round-color:transparent">.</span></div><div style=3D"font-size:small"><span=
 style=3D"font-size:13px;background-color:transparent;margin:0px;padding:0p=
x;border:0px rgb(34,34,34)"><br></span></div><div style=3D"font-size:small"=
><span style=3D"font-size:13px;background-color:transparent;margin:0px;padd=
ing:0px;border:0px rgb(34,34,34)">I can&#39;t see how this could be statica=
lly analysed. It&#39;s an undetectable logic error, since as far as the com=
piler is concerned, it has no way of knowing that C&#39;s <font face=3D"mon=
ospace, monospace">p</font> may outlive B&#39;s <font face=3D"monospace, mo=
nospace">up</font>.</span></div><div style=3D"font-size:small"><span style=
=3D"font-size:13px;background-color:transparent;margin:0px;padding:0px;bord=
er:0px rgb(34,34,34)"><br></span></div></span></span><div style=3D"font-siz=
e:13px"><span style=3D"background-color:transparent;margin:0px;padding:0px;=
border:0px rgb(34,34,34)"><span style=3D"background-color:transparent;margi=
n:0px;padding:0px;border:0px rgb(34,34,34)"><span style=3D"font-size:13px;b=
ackground-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)=
">Note that at the point of the construction of each of the 3 lambdas, the =
pointers captured are all valid (except in the crossing case where there is=
 a context switch after the post at B).</span></span></span></div></div></d=
iv></div></blockquote><div><br></div><div><br></div><div>In any case this d=
oes heap allocation for the views (the lambdas, inside the exec class) and =
presumably threading after that. Both are impossible to track. </div><div><=
br></div><div><br></div><div>For both however we have nice tools - shared a=
nd week ptr.=C2=A0</div><div><br></div><div>Which is ironic - the complex c=
ode is more safe then the trivial one. Yes you could use the heavyweight to=
ols for simple tasks, but that is not zero overhead any more.=C2=A0</div><d=
iv><br></div><div>Static analysis is the tool to help us with the common, s=
imple, yet (terribly) unsafe tasks, still keeping zero overhead.</div><div>=
<br></div><div><br></div><div>Having said that, there are scenarios where t=
racking will not give accurate prediction - the destruction might, for inst=
ance, depend upon some real time state.</div><div>That is the reason, these=
 cannot be errors, only warnings.</div><div>The compiler should, however, b=
e able to see all paths leading to destruction even the once behind real ti=
me check/uncertainty and warn that &quot;it <i>might </i>dangle&quot; or th=
at &quot;no one can be certain, even you!&quot;.</div><div><br></div><div>I=
n your example, the compiler should warn it can&#39;t predict the observer =
- has no visibility over its lifetime and/or the observed destruction is be=
hind real time uncertainty.=C2=A0<b><i></i></b></div><div>He might even sug=
gest alternative like share/weak ptr, because <i>observe_ptr was not the ri=
ght tool in the first place!</i> The compiler will only reaffirm that fact.=
=C2=A0</div><div><br></div><div>=C2=A0</div><blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;"><div dir=3D"ltr"><div><span style=3D"background-color:transpa=
rent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><div><span style=3D"b=
ackground-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)=
"><div style=3D"font-size:13px"><span style=3D"font-size:13px;background-co=
lor:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><br></span=
></div><div style=3D"font-size:13px"><span style=3D"font-size:13px;backgrou=
nd-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><br><=
/span></div></span></div></span></div></div><div><br><div class=3D"gmail_qu=
ote">On 20 January 2018 at 12:12,  <span dir=3D"ltr">&lt;<a onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;" href=3D"javascript:" target=3D"_blank" rel=
=3D"nofollow" gdf-obfuscated-mailto=3D"2Rr69cYVAwAJ">mihailn...@gmail.com</=
a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0=
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><sp=
an><br><br>On Friday, January 19, 2018 at 10:19:40 PM UTC+2, Nicol Bolas wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Friday, Jan=
uary 19, 2018 at 7:30:52 AM UTC-5, <a>mihailn...@gmail.com</a> wrote:<block=
quote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><font face=3D"arial=
,sans-serif"><span style=3D"text-align:left;color:rgb(34,34,34);text-transf=
orm:none;text-indent:0px;letter-spacing:normal;font-size:13px;font-style:no=
rmal;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:=
0px;display:inline!important;white-space:normal;float:none;background-color=
:transparent">Can we <span style=3D"display:inline!important;float:none;bac=
kground-color:transparent;color:rgb(34,34,34);font-family:arial,sans-serif;=
font-size:13px;font-style:normal;font-variant:normal;font-weight:400;letter=
-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-t=
ransform:none;white-space:normal;word-spacing:0px">&quot;just&quot; </span>=
define special behavior of=C2=A0<span style=3D"background-color:transparent=
;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-w=
idth:0px;border-left-color:rgb(34,34,34);border-left-style:none;border-left=
-width:0px;border-right-color:rgb(34,34,34);border-right-style:none;border-=
right-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;border=
-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-family:ar=
ial,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-we=
ight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;margin-rig=
ht:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px=
;padding-top:0px;text-align:left;text-decoration:none;text-indent:0px;text-=
transform:none;white-space:normal;word-spacing:0px">observer_ptr (in debug/=
analyze mode) and solve all cases of lifetime monitoring (under the said li=
mitations) - from smart pointers to function_view?</span></span></font></di=
v></div></blockquote><div><br></div><div>That&#39;s not &quot;behavior&quot=
; of the type. There is no actual code in `observer_ptr` that does anything=
 you&#39;re talking about. It&#39;s simply a compiler or tool that sees you=
 using this particular type and starts looking at things because of it.</di=
v></div></blockquote><div><br></div></span><div>If the constructor and rese=
t of <span style=3D"display:inline!important;float:none;background-color:tr=
ansparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helvetica=
&quot;,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font=
-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text=
-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">observ=
er_ptr are decorated with something like<font face=3D"courier new,monospace=
"> [[debug:observe_destruction]] </font>the=C2=A0<span style=3D"display:inl=
ine!important;float:none;background-color:transparent;color:rgb(34,34,34);f=
ont-family:&quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif;font-size:13p=
x;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:norm=
al;text-align:left;text-decoration:none;text-indent:0px;text-transform:none=
;white-space:normal;word-spacing:0px">behavior of=C2=A0<span>observer_ptr w=
ill be enforced by the compiler. </span></span></span></div><div><span styl=
e=3D"display:inline!important;float:none;background-color:transparent;color=
:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helvetica&quot;,sans-ser=
if;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;let=
ter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;tex=
t-transform:none;white-space:normal;word-spacing:0px"><span style=3D"displa=
y:inline!important;float:none;background-color:transparent;color:rgb(34,34,=
34);font-family:&quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif;font-siz=
e:13px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing=
:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform=
:none;white-space:normal;word-spacing:0px"><span><br></span></span></span><=
/div><div><span style=3D"display:inline!important;float:none;background-col=
or:transparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helv=
etica&quot;,sans-serif;font-size:13px;font-style:normal;font-variant:normal=
;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none=
;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><=
span style=3D"display:inline!important;float:none;background-color:transpar=
ent;color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helvetica&quot;=
,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weigh=
t:400;letter-spacing:normal;text-align:left;text-decoration:none;text-inden=
t:0px;text-transform:none;white-space:normal;word-spacing:0px"><span>The be=
havior, use and definition of observer_ptr are not changed. =C2=A0</span></=
span></span></div><span><div>=C2=A0</div><blockquote class=3D"gmail_quote" =
style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left=
:1ex"><div dir=3D"ltr"><div><br></div><div>It should also be noted that thi=
s still doesn&#39;t handle perfect forwarding. Not unless it is the caller =
of the function who wraps the parameter in an `observer_ptr`.</div></div></=
blockquote><div><br></div></span><div><font face=3D"courier new,monospace">=
class A_view</font></div><div><font face=3D"courier new,monospace">{</font>=
</div><div><font face=3D"courier new,monospace">=C2=A0 </font><font face=3D=
"courier new,monospace"><span style=3D"text-align:left;color:rgb(34,34,34);=
text-transform:none;text-indent:0px;letter-spacing:normal;font-size:13px;fo=
nt-style:normal;font-variant:normal;font-weight:400;text-decoration:none;wo=
rd-spacing:0px;display:inline!important;white-space:normal;float:none;backg=
round-color:transparent">A_view(const A* pa) : _p(pa) {}</span></font></div=
><div><font face=3D"courier new,monospace">=C2=A0 <span style=3D"text-align=
:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacin=
g:normal;font-size:13px;font-style:normal;font-variant:normal;font-weight:4=
00;text-decoration:none;word-spacing:0px;display:inline!important;white-spa=
ce:normal;float:none;background-color:transparent"><span>A_view(const A&amp=
; a) : _p(&amp;a) {}</span></span></font></div><div><font face=3D"courier n=
ew,monospace">=C2=A0 <span style=3D"text-align:left;color:rgb(34,34,34);tex=
t-transform:none;text-indent:0px;letter-spacing:normal;font-size:13px;font-=
variant:normal;word-spacing:0px;display:inline!important;white-space:normal=
;float:none;background-color:transparent"><span style=3D"margin:0px;padding=
:0px;border:0px rgb(34,34,34);text-align:left;color:rgb(34,34,34);text-tran=
sform:none;text-indent:0px;letter-spacing:normal;font-size:13px;font-varian=
t:normal;word-spacing:0px;display:inline;white-space:normal;float:none;back=
ground-color:transparent"><span>A_view(A&amp;&amp; a) : _p(&amp;a) {}</span=
></span></span></font></div><div><span style=3D"text-align:left;color:rgb(3=
4,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-siz=
e:13px;font-variant:normal;word-spacing:0px;display:inline!important;white-=
space:normal;float:none;background-color:transparent"><span style=3D"margin=
:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;color:rgb(34,34,3=
4);text-transform:none;text-indent:0px;letter-spacing:normal;font-size:13px=
;font-variant:normal;word-spacing:0px;display:inline;white-space:normal;flo=
at:none;background-color:transparent"><span><font face=3D"courier new,monos=
pace"><br></font></span></span></span></div><div><font face=3D"courier new,=
monospace">=C2=A0 <span style=3D"text-align:left;color:rgb(34,34,34);text-t=
ransform:none;text-indent:0px;letter-spacing:normal;font-size:13px;font-var=
iant:normal;word-spacing:0px;display:inline!important;white-space:normal;fl=
oat:none;background-color:transparent"><span style=3D"margin:0px;padding:0p=
x;border:0px rgb(34,34,34);text-align:left;color:rgb(34,34,34);text-transfo=
rm:none;text-indent:0px;letter-spacing:normal;font-size:13px;font-variant:n=
ormal;word-spacing:0px;display:inline;white-space:normal;float:none;backgro=
und-color:transparent"><span>observer_ptr&lt;const A&gt; _p;</span><b></b><=
/span></span></font></div><div><font face=3D"courier new,monospace">};=C2=
=A0</font></div><div><font face=3D"courier new"><br></font></div><div><font=
 face=3D"arial,sans-serif">observer_ptr will monitor addressof(*_p) for ~A(=
) call. The scope of monitoring is ~<span style=3D"text-align:left;color:rg=
b(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-=
size:13px;font-style:normal;font-variant:normal;font-weight:400;text-decora=
tion:none;word-spacing:0px;display:inline!important;white-space:normal;floa=
t:none;background-color:transparent">observer_ptr() or release() call.</spa=
n></font></div><div><font face=3D"arial,sans-serif"><span style=3D"text-ali=
gn:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spac=
ing:normal;font-size:13px;font-style:normal;font-variant:normal;font-weight=
:400;text-decoration:none;word-spacing:0px;display:inline!important;white-s=
pace:normal;float:none;background-color:transparent"><br></span></font></di=
v><div><font face=3D"arial,sans-serif"><span style=3D"text-align:left;color=
:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;fo=
nt-size:13px;font-style:normal;font-variant:normal;font-weight:400;text-dec=
oration:none;word-spacing:0px;display:inline!important;white-space:normal;f=
loat:none;background-color:transparent">Copies of=C2=A0<span style=3D"margi=
n:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;color:rgb(34,34,=
34);text-transform:none;text-indent:0px;letter-spacing:normal;font-size:13p=
x;font-style:normal;font-variant:normal;font-weight:400;text-decoration:non=
e;word-spacing:0px;display:inline;white-space:normal;float:none;background-=
color:transparent"><span style=3D"background-color:transparent;border-botto=
m-color:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0px;bord=
er-left-color:rgb(34,34,34);border-left-style:none;border-left-width:0px;bo=
rder-right-color:rgb(34,34,34);border-right-style:none;border-right-width:0=
px;border-top-color:rgb(34,34,34);border-top-style:none;border-top-width:0p=
x;color:rgb(34,34,34);display:inline;float:none;font-size:13px;font-style:n=
ormal;font-variant:normal;font-weight:400;letter-spacing:normal;margin-bott=
om:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:0px;p=
adding-left:0px;padding-right:0px;padding-top:0px;text-align:left;text-deco=
ration:none;text-indent:0px;text-transform:none;white-space:normal;word-spa=
cing:0px"><span style=3D"background-color:transparent;border-bottom-color:r=
gb(34,34,34);border-bottom-style:none;border-bottom-width:0px;border-left-c=
olor:rgb(34,34,34);border-left-style:none;border-left-width:0px;border-righ=
t-color:rgb(34,34,34);border-right-style:none;border-right-width:0px;border=
-top-color:rgb(34,34,34);border-top-style:none;border-top-width:0px;color:r=
gb(34,34,34);display:inline;float:none;font-size:13px;font-style:normal;fon=
t-variant:normal;font-weight:400;letter-spacing:normal;margin-bottom:0px;ma=
rgin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:0px;padding-le=
ft:0px;padding-right:0px;padding-top:0px;text-align:left;text-decoration:no=
ne;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"=
><font face=3D"arial,sans-serif">observer_ptr still monitor the same addres=
s, but with a different scope - their dtor, release or reset.</font></span>=
</span></span></span></font><font face=3D"arial,sans-serif"><span style=3D"=
text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;let=
ter-spacing:normal;font-size:13px;font-style:normal;font-variant:normal;fon=
t-weight:400;text-decoration:none;word-spacing:0px;display:inline!important=
;white-space:normal;float:none;background-color:transparent"><span style=3D=
"margin:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;color:rgb(=
34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-si=
ze:13px;font-style:normal;font-variant:normal;font-weight:400;text-decorati=
on:none;word-spacing:0px;display:inline;white-space:normal;float:none;backg=
round-color:transparent"><span style=3D"background-color:transparent;border=
-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0p=
x;border-left-color:rgb(34,34,34);border-left-style:none;border-left-width:=
0px;border-right-color:rgb(34,34,34);border-right-style:none;border-right-w=
idth:0px;border-top-color:rgb(34,34,34);border-top-style:none;border-top-wi=
dth:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13px;font-s=
tyle:normal;font-variant:normal;font-weight:400;letter-spacing:normal;margi=
n-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom=
:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:left;tex=
t-decoration:none;text-indent:0px;text-transform:none;white-space:normal;wo=
rd-spacing:0px"><span style=3D"background-color:transparent;border-bottom-c=
olor:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0px;border-=
left-color:rgb(34,34,34);border-left-style:none;border-left-width:0px;borde=
r-right-color:rgb(34,34,34);border-right-style:none;border-right-width:0px;=
border-top-color:rgb(34,34,34);border-top-style:none;border-top-width:0px;c=
olor:rgb(34,34,34);display:inline;float:none;font-size:13px;font-style:norm=
al;font-variant:normal;font-weight:400;letter-spacing:normal;margin-bottom:=
0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:0px;padd=
ing-left:0px;padding-right:0px;padding-top:0px;text-align:left;text-decorat=
ion:none;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:0px"></span></span></span></span></font></div><div><font face=3D"arial,sa=
ns-serif"><span style=3D"text-align:left;color:rgb(34,34,34);text-transform=
:none;text-indent:0px;letter-spacing:normal;font-size:13px;font-style:norma=
l;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px=
;display:inline!important;white-space:normal;float:none;background-color:tr=
ansparent"><span style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);t=
ext-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;lett=
er-spacing:normal;font-size:13px;font-style:normal;font-variant:normal;font=
-weight:400;text-decoration:none;word-spacing:0px;display:inline;white-spac=
e:normal;float:none;background-color:transparent"><span style=3D"background=
-color:transparent;border-bottom-color:rgb(34,34,34);border-bottom-style:no=
ne;border-bottom-width:0px;border-left-color:rgb(34,34,34);border-left-styl=
e:none;border-left-width:0px;border-right-color:rgb(34,34,34);border-right-=
style:none;border-right-width:0px;border-top-color:rgb(34,34,34);border-top=
-style:none;border-top-width:0px;color:rgb(34,34,34);display:inline;float:n=
one;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;le=
tter-spacing:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;marg=
in-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-to=
p:0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:n=
one;white-space:normal;word-spacing:0px"><span style=3D"background-color:tr=
ansparent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border=
-bottom-width:0px;border-left-color:rgb(34,34,34);border-left-style:none;bo=
rder-left-width:0px;border-right-color:rgb(34,34,34);border-right-style:non=
e;border-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:no=
ne;border-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-=
size:13px;font-style:normal;font-variant:normal;font-weight:400;letter-spac=
ing:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0p=
x;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;tex=
t-align:left;text-decoration:none;text-indent:0px;text-transform:none;white=
-space:normal;word-spacing:0px"><br></span></span></span></span></font></di=
v><font face=3D"arial,sans-serif"><span style=3D"text-align:left;color:rgb(=
34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-si=
ze:13px;font-style:normal;font-variant:normal;font-weight:400;text-decorati=
on:none;word-spacing:0px;display:inline!important;white-space:normal;float:=
none;background-color:transparent"><span style=3D"margin:0px;padding:0px;bo=
rder:0px rgb(34,34,34);text-align:left;color:rgb(34,34,34);text-transform:n=
one;text-indent:0px;letter-spacing:normal;font-size:13px;font-style:normal;=
font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;d=
isplay:inline;white-space:normal;float:none;background-color:transparent"><=
span style=3D"background-color:transparent;border-bottom-color:rgb(34,34,34=
);border-bottom-style:none;border-bottom-width:0px;border-left-color:rgb(34=
,34,34);border-left-style:none;border-left-width:0px;border-right-color:rgb=
(34,34,34);border-right-style:none;border-right-width:0px;border-top-color:=
rgb(34,34,34);border-top-style:none;border-top-width:0px;color:rgb(34,34,34=
);display:inline;float:none;font-size:13px;font-style:normal;font-variant:n=
ormal;font-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0=
px;margin-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padd=
ing-right:0px;padding-top:0px;text-align:left;text-decoration:none;text-ind=
ent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span styl=
e=3D"background-color:transparent;border-bottom-color:rgb(34,34,34);border-=
bottom-style:none;border-bottom-width:0px;border-left-color:rgb(34,34,34);b=
order-left-style:none;border-left-width:0px;border-right-color:rgb(34,34,34=
);border-right-style:none;border-right-width:0px;border-top-color:rgb(34,34=
,34);border-top-style:none;border-top-width:0px;color:rgb(34,34,34);display=
:inline;float:none;font-size:13px;font-style:normal;font-variant:normal;fon=
t-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;margin=
-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right=
:0px;padding-top:0px;text-align:left;text-decoration:none;text-indent:0px;t=
ext-transform:none;white-space:normal;word-spacing:0px"><div><br></div></sp=
an></span></span></span></font><div><font face=3D"arial,sans-serif"><span s=
tyle=3D"text-align:left;color:rgb(34,34,34);text-transform:none;text-indent=
:0px;letter-spacing:normal;font-size:13px;font-style:normal;font-variant:no=
rmal;font-weight:400;text-decoration:none;word-spacing:0px;display:inline!i=
mportant;white-space:normal;float:none;background-color:transparent"><span =
style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;co=
lor:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal=
;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;text-=
decoration:none;word-spacing:0px;display:inline;white-space:normal;float:no=
ne;background-color:transparent"><span style=3D"background-color:transparen=
t;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-=
width:0px;border-left-color:rgb(34,34,34);border-left-style:none;border-lef=
t-width:0px;border-right-color:rgb(34,34,34);border-right-style:none;border=
-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;borde=
r-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13p=
x;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:norm=
al;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;paddin=
g-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:=
left;text-decoration:none;text-indent:0px;text-transform:none;white-space:n=
ormal;word-spacing:0px"><span style=3D"background-color:transparent;border-=
bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0px=
;border-left-color:rgb(34,34,34);border-left-style:none;border-left-width:0=
px;border-right-color:rgb(34,34,34);border-right-style:none;border-right-wi=
dth:0px;border-top-color:rgb(34,34,34);border-top-style:none;border-top-wid=
th:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13px;font-st=
yle:normal;font-variant:normal;font-weight:400;letter-spacing:normal;margin=
-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:=
0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:left;text=
-decoration:none;text-indent:0px;text-transform:none;white-space:normal;wor=
d-spacing:0px">That is a major difference from lifetime extension - we can =
have many-to-one mapping without any semantic or implementation problems.=
=C2=A0<span style=3D"display:inline!important;float:none;background-color:t=
ransparent;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;=
font-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal=
;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;w=
hite-space:normal;word-spacing:0px">Lifetime extension does not allow copie=
s of a view/ref to extend with the lifetime of the object.</span></span></s=
pan></span></span></font></div><div><font face=3D"arial,sans-serif"><span s=
tyle=3D"text-align:left;color:rgb(34,34,34);text-transform:none;text-indent=
:0px;letter-spacing:normal;font-size:13px;font-style:normal;font-variant:no=
rmal;font-weight:400;text-decoration:none;word-spacing:0px;display:inline!i=
mportant;white-space:normal;float:none;background-color:transparent"><span =
style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;co=
lor:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal=
;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;text-=
decoration:none;word-spacing:0px;display:inline;white-space:normal;float:no=
ne;background-color:transparent"><span style=3D"background-color:transparen=
t;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-=
width:0px;border-left-color:rgb(34,34,34);border-left-style:none;border-lef=
t-width:0px;border-right-color:rgb(34,34,34);border-right-style:none;border=
-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;borde=
r-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13p=
x;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:norm=
al;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;paddin=
g-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:=
left;text-decoration:none;text-indent:0px;text-transform:none;white-space:n=
ormal;word-spacing:0px"><span style=3D"background-color:transparent;border-=
bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0px=
;border-left-color:rgb(34,34,34);border-left-style:none;border-left-width:0=
px;border-right-color:rgb(34,34,34);border-right-style:none;border-right-wi=
dth:0px;border-top-color:rgb(34,34,34);border-top-style:none;border-top-wid=
th:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13px;font-st=
yle:normal;font-variant:normal;font-weight:400;letter-spacing:normal;margin=
-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:=
0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:left;text=
-decoration:none;text-indent:0px;text-transform:none;white-space:normal;wor=
d-spacing:0px">We are also not limited to initialization only - the monitor=
ing can (re)start at the call of reset() instead on constructor call only. =
Lifetime extension deals with initialization exclusively.=C2=A0</span></spa=
n></span></span></font></div><div><font face=3D"arial,sans-serif"><span sty=
le=3D"text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0=
px;letter-spacing:normal;font-size:13px;font-style:normal;font-variant:norm=
al;font-weight:400;text-decoration:none;word-spacing:0px;display:inline!imp=
ortant;white-space:normal;float:none;background-color:transparent"><span st=
yle=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;colo=
r:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;f=
ont-size:13px;font-style:normal;font-variant:normal;font-weight:400;text-de=
coration:none;word-spacing:0px;display:inline;white-space:normal;float:none=
;background-color:transparent"><span style=3D"background-color:transparent;=
border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-wi=
dth:0px;border-left-color:rgb(34,34,34);border-left-style:none;border-left-=
width:0px;border-right-color:rgb(34,34,34);border-right-style:none;border-r=
ight-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;border-=
top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13px;=
font-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal=
;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-=
bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:le=
ft;text-decoration:none;text-indent:0px;text-transform:none;white-space:nor=
mal;word-spacing:0px"><span style=3D"background-color:transparent;border-bo=
ttom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0px;b=
order-left-color:rgb(34,34,34);border-left-style:none;border-left-width:0px=
;border-right-color:rgb(34,34,34);border-right-style:none;border-right-widt=
h:0px;border-top-color:rgb(34,34,34);border-top-style:none;border-top-width=
:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13px;font-styl=
e:normal;font-variant:normal;font-weight:400;letter-spacing:normal;margin-b=
ottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:0p=
x;padding-left:0px;padding-right:0px;padding-top:0px;text-align:left;text-d=
ecoration:none;text-indent:0px;text-transform:none;white-space:normal;word-=
spacing:0px"><br></span></span></span></span></font></div><div><font face=
=3D"arial,sans-serif"><span style=3D"text-align:left;color:rgb(34,34,34);te=
xt-transform:none;text-indent:0px;letter-spacing:normal;font-size:13px;font=
-style:normal;font-variant:normal;font-weight:400;text-decoration:none;word=
-spacing:0px;display:inline!important;white-space:normal;float:none;backgro=
und-color:transparent"><span style=3D"margin:0px;padding:0px;border:0px rgb=
(34,34,34);text-align:left;color:rgb(34,34,34);text-transform:none;text-ind=
ent:0px;letter-spacing:normal;font-size:13px;font-style:normal;font-variant=
:normal;font-weight:400;text-decoration:none;word-spacing:0px;display:inlin=
e;white-space:normal;float:none;background-color:transparent"><span style=
=3D"background-color:transparent;border-bottom-color:rgb(34,34,34);border-b=
ottom-style:none;border-bottom-width:0px;border-left-color:rgb(34,34,34);bo=
rder-left-style:none;border-left-width:0px;border-right-color:rgb(34,34,34)=
;border-right-style:none;border-right-width:0px;border-top-color:rgb(34,34,=
34);border-top-style:none;border-top-width:0px;color:rgb(34,34,34);display:=
inline;float:none;font-size:13px;font-style:normal;font-variant:normal;font=
-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;margin-=
right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right:=
0px;padding-top:0px;text-align:left;text-decoration:none;text-indent:0px;te=
xt-transform:none;white-space:normal;word-spacing:0px"><span style=3D"backg=
round-color:transparent;border-bottom-color:rgb(34,34,34);border-bottom-sty=
le:none;border-bottom-width:0px;border-left-color:rgb(34,34,34);border-left=
-style:none;border-left-width:0px;border-right-color:rgb(34,34,34);border-r=
ight-style:none;border-right-width:0px;border-top-color:rgb(34,34,34);borde=
r-top-style:none;border-top-width:0px;color:rgb(34,34,34);display:inline;fl=
oat:none;font-size:13px;font-style:normal;font-variant:normal;font-weight:4=
00;letter-spacing:normal;margin-bottom:0px;margin-left:0px;margin-right:0px=
;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;paddi=
ng-top:0px;text-align:left;text-decoration:none;text-indent:0px;text-transf=
orm:none;white-space:normal;word-spacing:0px"><br></span></span></span></sp=
an></font></div><div>How can perfect forwarding interfere in all this?=C2=
=A0</div><div><br></div><div><br></div><div><font face=3D"courier new,monos=
pace"><span>template&lt;typename T, typename ...Args&gt;<br></span>auto ini=
t(Args&amp;&amp;... arg)<br>{<br>=C2=A0 return T(std::forward&lt;Args&gt;(a=
rg)...); //&lt; observer_ptr starts monitoring &amp;arg<br>}<br><br>int mai=
n()<br>{ <br>=C2=A0 auto v =3D init&lt;A_view&gt;(A{}); //&lt; both A_view =
and A allocated. A_view usable before the &#39;;&#39; when ~A is called<br>=
}</font></div><div><font face=3D"courier new"><br></font></div><div>If copy=
 elision does not kick-in nothing changes - copy is safe and defined, lifet=
ime of A is the same.</div><div><br></div><div>If we pass arguments and cre=
ate A in init() instead ( <font face=3D"courier new,monospace">return</font=
>=C2=A0 <span style=3D"display:inline!important;float:none;background-color=
:transparent;color:rgb(34,34,34);font-family:courier new,monospace;font-siz=
e:13px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing=
:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform=
:none;white-space:normal;word-spacing:0px">T(A(std::forward&lt;Args&gt;(arg=
)...<wbr>)); </span>), then the <font face=3D"courier new,monospace">observ=
er_ptr </font>is still created with a valid address, </div><div>however, af=
ter we return will not be able to use<font face=3D"courier new,monospace"> =
A_view</font> in any way, including before the <font face=3D"courier new,mo=
nospace">&#39;;&#39;.=C2=A0</font></div><div><b></b><i></i><u></u><sub></su=
b><sup></sup><strike></strike><font face=3D"courier new,monospace"><br></fo=
nt></div><div>If both there is no elision and A is created when initializin=
g T inside init, then the returned view can be created from a dangling view=
..=C2=A0</div><div>We could allow views from dangling views to be created, h=
owever=C2=A0<span style=3D"display:inline!important;float:none;background-c=
olor:transparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;He=
lvetica&quot;,sans-serif;font-size:13px;font-style:normal;font-variant:norm=
al;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:no=
ne;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"=
>no dtor will be monitored and</span> all uses of the view will be illegal =
until destroyed/reset/release-ed. </div><div>We could also issue a warning =
on coping from dangling view without problem.</div><div><br></div><div><br>=
</div><div><br></div><div><font face=3D"arial,sans-serif"><b><i><br></i></b=
></font></div><div>=C2=A0</div></div><span>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" o=
nclick=3D"this.href=3D&#39;javascript:&#39;;return true;" href=3D"javascrip=
t:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=3D"2Rr69cYVAwA=
J">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a onmousedown=3D"this.href=3D&#39;jav=
ascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;re=
turn true;" href=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obf=
uscated-mailto=3D"2Rr69cYVAwAJ">std-pr...@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a onmousedown=3D"this.href=3D&#39=
;https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4fa792ec-1f51=
-4357-a65a-2ce3c10c60c0%40isocpp.org?utm_medium\x3demail\x26utm_source\x3df=
ooter&#39;;return true;" onclick=3D"this.href=3D&#39;https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4fa792ec-1f51-4357-a65a-2ce3c10c60c0=
%40isocpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;=
" href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4fa7=
92ec-1f51-4357-a65a-2ce3c10c60c0%40isocpp.org?utm_medium=3Demail&amp;utm_so=
urce=3Dfooter" target=3D"_blank" rel=3D"nofollow">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/4fa792ec-1f51-4357-<wbr>a65a-=
2ce3c10c60c0%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div>
</blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/00d91d4c-4ee7-4dbd-a547-3dd844f5685d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/00d91d4c-4ee7-4dbd-a547-3dd844f5685d=
%40isocpp.org</a>.<br />

------=_Part_2494_1021269791.1516466168924--

------=_Part_2493_1727009190.1516466168923--

.
