220 36721 <CALvx3hYQHFXi5eRrcdCGEqWj-n4w4NKYDpRx4G_U16i+2VS5nQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Richard Hodges <hodges.r@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Static analysis and the future of C++
Date: Sat, 20 Jan 2018 15:54:50 +0100
Lines: 674
Approved: news@gmane.org
Message-ID: <CALvx3hYQHFXi5eRrcdCGEqWj-n4w4NKYDpRx4G_U16i+2VS5nQ@mail.gmail.com>
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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a114411780b9ee7056336617d"
X-Trace: blaine.gmane.org 1516459984 11076 195.159.176.226 (20 Jan 2018 14:53:04 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 20 Jan 2018 14:53:04 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD4PBM7UWAHRBPFQRXJQKGQETKTGZAI@isocpp.org Sat Jan 20 15:52:59 2018
Return-path: <std-proposals+bncBD4PBM7UWAHRBPFQRXJQKGQETKTGZAI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f71.google.com ([209.85.214.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD4PBM7UWAHRBPFQRXJQKGQETKTGZAI@isocpp.org>)
	id 1ecuVl-0001yD-6w
	for gclcip-std-proposals@m.gmane.org; Sat, 20 Jan 2018 15:52:49 +0100
Original-Received: by mail-it0-f71.google.com with SMTP id k19sf5074417ita.8
        for <gclcip-std-proposals@m.gmane.org>; Sat, 20 Jan 2018 06:54:53 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1516460093; cv=pass;
        d=google.com; s=arc-20160816;
        b=V9e5fd6If9XzFXrLF9isc1AIA9qUN41hFsoKx9Z9bFOlT/Mku0ZKnsfzwF0t1z4y6k
         Fb+fQlSYGDiIuOhm0CUmrs1R10fkFz1WplrizaJ/BiGnfQS6gbPfCIUIE3Lk5lJGj9VY
         sxwJT1cxTTOOkEqnFyhB19QrjTbOXFJulkftZgCd/8EdxTVGCfeNeUVens1oNlQtW1Rd
         oTf4hYhokP9h6Nece/oOe8w67fIgsxV7S74HYkuvAnXt0sQHX7SR2O3mlDrWuhy2FUh4
         DmdZVA3VNHYopraJvQahr17wF8uTO05mCJUiLYu9gpenSWZr/g7ulA18IMzCBm9snPUr
         c5+A==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=yBgsr51cjaCoPAF7JlSU1cZrMA8B5+29ErQz5SDi5ZQ=;
        b=lFkf4PEE5qXRnlTRaVcU2GEqP+yk0GpK5cf5BYtrrq2Jpjk7r3bE3ZrC8Wpy9bO5ew
         cvqjiH2mHvN13MmVMXtWCVL6feP+RAm7FFMAW3nJwQSbT+BrgyUMZKvQlxS3IGZFkaPx
         keBoT6NoEcYFHam9umwOXSnMhO2MFIuw3LeWnagJ0XDfxQrkSvEe4Rsq79oz9JjcoHvw
         UCL7HwQTNDpBXWcFNElDCwn5jtkuEPfmxMQIz+qwdY4oiUXxq4OhrrfR42Qk13xNQ15j
         Q9dcrFT1+asxyN/OSgH1Ow5FFqYmtEdgQ+3jWe4WFc6+MuiA3nNEddjM6sBFyyzuAidZ
         NO9A==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=oap22XQg;
       spf=pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=hodges.r@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=yBgsr51cjaCoPAF7JlSU1cZrMA8B5+29ErQz5SDi5ZQ=;
        b=GwWO6Dl1tQ2GV6ieb5cboJyRY6GUncHXO4twmNx2r14DZYsm5CL0+Z8uRwENBHjvg6
         1nxYBSsJZzYwFtY5IFTGVPp8nPPjcPoQ1l5uM5tGi2wYhtFxu4jA/rmoi/UxGEXsVVqE
         OKUhPfy4pboFPQRJ20OZNnw77+9MqQG30kb7uGfd7T7OaX56o0M/5wSnn1Qcm7lzhbH3
         ANXDt5gS3NH1SxN+Flb9lcg1AqQtcq02dLotXQBp88+boNH6b49q5S5slnR7h/HqpjGJ
         lMWtZbidBMf29L+2NwaSDy1JbV7rJLzROBpo+BnzvpDo/0MzGXKUWQoUkMRRa1/MuVgH
         +C7g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject: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=yBgsr51cjaCoPAF7JlSU1cZrMA8B5+29ErQz5SDi5ZQ=;
        b=PC1I1iekKIXWe/S3u2ZnN/fucQluIpBZ5XbLGXoELeYVByJoNMU+bCfnjxZ/YGtM7I
         X7tTRzf/zdtZsWIhCwTrShorZFet/jrYlM6WWzW6hhAGdFXQlukcXqClIr5BokGkHi6v
         3hylAAmyi69lfyAcDQCeazRXcU8akBpof/FCSSijy3IBLPwyNBKStmXsesu9YAjq+TlB
         Uy/bu7VtiMHlbZPHFkYzgYMeZUK+AGv9vhhEHo5a/oo18eu11yZ0c7W3e8oK7Wrc5NPV
         9QsutFzmspU4NAtPCm/oaUkjoMpFxD/LNZPJISzhiClq9ah6oxZwQTy2it1NuTMtal5y
         cJTQ==
X-Gm-Message-State: AKwxyte9TGAzfnsaR92U7exXYqlV18STOxRoiUuKJaZtg+xjhlM+O9Ur
	cl9RgxNSeGcdcOFzOlay7NWeBw==
X-Google-Smtp-Source: AH8x224umEUBjJqlIpbvcm43CQdenz7KNvuIPLZWhfq1DeVOa1wWDmAWV0/ZZ0QXSTAtsWO++kasew==
X-Received: by 10.107.152.133 with SMTP id a127mr1550888ioe.47.1516460093270;
        Sat, 20 Jan 2018 06:54:53 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.73.74 with SMTP id z71ls803060ita.6.gmail; Sat, 20 Jan 2018
 06:54:51 -0800 (PST)
X-Received: by 10.36.77.139 with SMTP id l133mr1720086itb.52.1516460091816;
        Sat, 20 Jan 2018 06:54:51 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1516460091; cv=none;
        d=google.com; s=arc-20160816;
        b=Hr0Lg5iPd2eqm15QQL7ibD5B7VTvYnqaxW3NNMWCw5z6pLZIMluNO0Qnt9yDUPQQgs
         Hth4ouyQM7CiXPXK8Uoeg/cB4diOZJz6f8uZrc+TnA/Vc7ln0CJHru9SAbj6aCuuZWKl
         KWlaNjstW7LKtm7GQ2AiTGO5DYCgybs/VYbVAnxwSeVJU7LFy7L6PNEDbI2U/JdZolOT
         4pL+5FA0WvutAMYIk8js6iZi2uAg+nEjHuuy66qFKVnhG7cF+Ls539zt2u4A/lBGVDDI
         fcYBDVXXDVMQ5vY8Hp9clvQYfL3/dqpVwYLc5wd8uLPnZQpHZKat0Xl2zLLbOzHniavp
         0WvQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=JdZ3Zu7Lsa27XksT4vJFtAITbzva1E/ZyI3HBFTslHA=;
        b=x2j+2tB52RXUWBA/nxT9xQHlm/qqbNNMICrPL4jo4N8wvrqOREgMY7F/6RKoiSPPLZ
         itH1lcAdphjp/HsHxiHJPuaIh1nK6d4/v0wkmKEbwSUr5DS4EIm1suVpSDX4pXFDXHOP
         MWh7dVqmhJQPAMDYLu0I6hU0LthuEMmqL9N81atQTnFePIof8w7lY1FX8RycJmiAm3mW
         JFGjeGLLpPP/5aVlZvD7YMkCHOvNyatLTX5VxM5MaWdkPTa8e+0MAvEHl4JvF9mw+RHH
         +olC61wTtuLmJjg1jjnIY1ef53Hbo8CKDo3ifqhkPSvahBzUsbDpRrCFCluL6Q0o8XF6
         uwiQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=oap22XQg;
       spf=pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=hodges.r@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id 135sor1676568ity.23.2018.01.20.06.54.51
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sat, 20 Jan 2018 06:54:51 -0800 (PST)
Received-SPF: pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.36.26.74 with SMTP id 71mr1879988iti.32.1516460091087; Sat,
 20 Jan 2018 06:54:51 -0800 (PST)
Original-Received: by 10.2.164.138 with HTTP; Sat, 20 Jan 2018 06:54:50 -0800 (PST)
In-Reply-To: <4fa792ec-1f51-4357-a65a-2ce3c10c60c0@isocpp.org>
X-Original-Sender: hodges.r@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=oap22XQg;       spf=pass
 (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=hodges.r@gmail.com;       dmarc=pass (p=NONE
 sp=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-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:36721
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36721>

--001a114411780b9ee7056336617d
Content-Type: text/plain; charset="UTF-8"

> 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).



On 20 January 2018 at 12:12, <mihailnajdenov@gmail.com> 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-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/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/CALvx3hYQHFXi5eRrcdCGEqWj-n4w4NKYDpRx4G_U16i%2B2VS5nQ%40mail.gmail.com.

--001a114411780b9ee7056336617d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">&gt;=C2=A0<span style=3D"font-size:13px">Copies of=C2=A0</=
span><span style=3D"font-size:13px;font-variant-numeric:normal;font-variant=
-east-asian:normal;background-color:transparent;margin:0px;padding:0px;bord=
er: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;font-variant-numeric:normal;font-variant-east-asian:norm=
al;background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34=
,34)"><br></span></div><div><span style=3D"font-size:13px;font-variant-nume=
ric:normal;font-variant-east-asian:normal;background-color:transparent;marg=
in: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;font-variant-numeric=
:normal;font-variant-east-asian:normal;background-color:transparent;margin:=
0px;padding:0px;border:0px rgb(34,34,34)"><br></span></div><div><span style=
=3D"font-size:13px;font-variant-numeric:normal;font-variant-east-asian:norm=
al;background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34=
,34)">consider</span></div><div><span style=3D"font-size:13px;font-variant-=
numeric:normal;font-variant-east-asian:normal;background-color:transparent;=
margin:0px;padding:0px;border:0px rgb(34,34,34)"><br></span></div><div><spa=
n style=3D"font-size:13px;font-variant-numeric:normal;font-variant-east-asi=
an:normal;background-color:transparent;margin:0px;padding:0px;border:0px rg=
b(34,34,34)"><font face=3D"monospace, monospace">auto&amp; exec =3D some_as=
ync_executor();</font></span></div><div><span style=3D"font-size:13px;font-=
variant-numeric:normal;font-variant-east-asian:normal;background-color:tran=
sparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><font face=3D"mono=
space, monospace">auto up =3D std::make_unique&lt;Foo&gt;();</font></span><=
/div><div><span style=3D"font-size:13px;font-variant-numeric:normal;font-va=
riant-east-asian:normal;background-color:transparent;margin:0px;padding:0px=
;border:0px rgb(34,34,34)"><font face=3D"monospace, monospace"><br></font><=
/span></div><div><span style=3D"font-size:13px;font-variant-numeric:normal;=
font-variant-east-asian:normal;background-color:transparent;margin:0px;padd=
ing: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"f=
ont-size:13px;font-variant-numeric:normal;font-variant-east-asian:normal;ba=
ckground-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 // A</font></span></div></div><div><span style=3D"font-varia=
nt-numeric:normal;font-variant-east-asian:normal;background-color:transpare=
nt;margin:0px;padding:0px;border:0px rgb(34,34,34)"><div style=3D"font-size=
:small"><span style=3D"font-size:13px;font-variant-numeric:normal;font-vari=
ant-east-asian:normal;background-color:transparent;margin:0px;padding:0px;b=
order:0px rgb(34,34,34)"><font face=3D"monospace, monospace">exec.post([up =
=3D std::move(up)] { something_with(*up); }); // B</font></span></div><div>=
<span style=3D"font-variant-numeric:normal;font-variant-east-asian:normal;b=
ackground-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)=
"><div style=3D"font-size:small"><span style=3D"font-size:13px;font-variant=
-numeric:normal;font-variant-east-asian:normal;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;fo=
nt-variant-numeric:normal;font-variant-east-asian:normal;background-color:t=
ransparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><br></span></di=
v><div>Assume that B&#39;s lambda invocation may or may not complete before=
 C&#39;s=C2=A0<span style=3D"background-color:transparent">lambda invocatio=
n</span><span style=3D"background-color:transparent">.</span></div><div sty=
le=3D"font-size:small"><span style=3D"font-size:13px;font-variant-numeric:n=
ormal;font-variant-east-asian:normal;background-color:transparent;margin:0p=
x;padding:0px;border:0px rgb(34,34,34)"><br></span></div><div style=3D"font=
-size:small"><span style=3D"font-size:13px;font-variant-numeric:normal;font=
-variant-east-asian:normal;background-color:transparent;margin:0px;padding:=
0px;border:0px rgb(34,34,34)">I can&#39;t see how this could be statically =
analysed. It&#39;s an undetectable logic error, since as far as the compile=
r is concerned, it has no way of knowing that C&#39;s <font face=3D"monospa=
ce, monospace">p</font> may outlive B&#39;s <font face=3D"monospace, monosp=
ace">up</font>.</span></div><div style=3D"font-size:small"><span style=3D"f=
ont-size:13px;font-variant-numeric:normal;font-variant-east-asian:normal;ba=
ckground-color: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:13=
px;font-variant-numeric:normal;font-variant-east-asian:normal;background-co=
lor: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 cap=
tured are all valid (except in the crossing case where there is a context s=
witch after the post at B).</span></div><div style=3D"font-size:13px"><span=
 style=3D"font-size:13px;font-variant-numeric:normal;font-variant-east-asia=
n:normal;background-color:transparent;margin:0px;padding:0px;border:0px rgb=
(34,34,34)"><br></span></div><div style=3D"font-size:13px"><span style=3D"f=
ont-size:13px;font-variant-numeric:normal;font-variant-east-asian:normal;ba=
ckground-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"=
><br></span></div></span></div></span></div></div><div class=3D"gmail_extra=
"><br><div class=3D"gmail_quote">On 20 January 2018 at 12:12,  <span dir=3D=
"ltr">&lt;<a href=3D"mailto:mihailnajdenov@gmail.com" target=3D"_blank">mih=
ailnajdenov@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"ltr"><span class=3D""><br><br>On Friday, January 19, 2018 at=
 10:19:40 PM UTC+2, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" sty=
le=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"ltr">On Friday, January 19, 2018 at 7:30:52 AM UTC-5, <a>mih=
ailn...@gmail.com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div di=
r=3D"ltr"><div><font face=3D"arial,sans-serif"><span style=3D"text-align:le=
ft;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:n=
ormal;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;background-color:transparent">Can we <span style=3D"displ=
ay:inline!important;float:none;background-color:transparent;color:rgb(34,34=
,34);font-family:arial,sans-serif;font-size:13px;font-style:normal;font-var=
iant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-deco=
ration:none;text-indent:0px;text-transform:none;white-space:normal;word-spa=
cing:0px">&quot;just&quot; </span>define special behavior of=C2=A0<span sty=
le=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,3=
4);border-right-style:none;border-right-width:0px;border-top-color:rgb(34,3=
4,34);border-top-style:none;border-top-width:0px;color:rgb(34,34,34);displa=
y:inline;float:none;font-family:arial,sans-serif;font-size:13px;font-style:=
normal;font-variant:normal;font-weight:400;letter-spacing:normal;margin-bot=
tom: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-dec=
oration:none;text-indent:0px;text-transform:none;white-space:normal;word-sp=
acing:0px">observer_ptr (in debug/analyze mode) and solve all cases of life=
time monitoring (under the said limitations) - from smart pointers to funct=
ion_view?</span></span></font></div></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 simpl=
y a compiler or tool that sees you using this particular type and starts lo=
oking at things because of it.</div></div></blockquote><div><br></div></spa=
n><div>If the constructor and reset of <span style=3D"display:inline!import=
ant;float:none;background-color:transparent;color:rgb(34,34,34);font-family=
:&quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif;font-size:13px;font-sty=
le:normal;font-variant:normal;font-weight:400;letter-spacing:normal;text-al=
ign:left;text-decoration:none;text-indent:0px;text-transform:none;white-spa=
ce:normal;word-spacing:0px">observer_ptr are decorated with something like<=
font face=3D"courier new,monospace"> [[debug:observe_destruction]] </font>t=
he=C2=A0<span style=3D"display:inline!important;float:none;background-color=
:transparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helvet=
ica&quot;,sans-serif;font-size:13px;font-style:normal;font-variant:normal;f=
ont-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;t=
ext-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">beh=
avior of=C2=A0<span>observer_ptr will be enforced by the compiler. </span><=
/span></span></div><div><span style=3D"display:inline!important;float:none;=
background-color:transparent;color:rgb(34,34,34);font-family:&quot;Arial&qu=
ot;,&quot;Helvetica&quot;,sans-serif;font-size:13px;font-style:normal;font-=
variant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-d=
ecoration:none;text-indent:0px;text-transform:none;white-space:normal;word-=
spacing:0px"><span style=3D"display:inline!important;float:none;background-=
color:transparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;H=
elvetica&quot;,sans-serif;font-size:13px;font-style:normal;font-variant:nor=
mal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:n=
one;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px=
"><span><br></span></span></span></div><div><span style=3D"display:inline!i=
mportant;float:none;background-color:transparent;color:rgb(34,34,34);font-f=
amily:&quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif;font-size:13px;fon=
t-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal;te=
xt-align:left;text-decoration:none;text-indent:0px;text-transform:none;whit=
e-space:normal;word-spacing:0px"><span style=3D"display:inline!important;fl=
oat:none;background-color:transparent;color:rgb(34,34,34);font-family:&quot=
;Arial&quot;,&quot;Helvetica&quot;,sans-serif;font-size:13px;font-style:nor=
mal;font-variant:normal;font-weight:400;letter-spacing:normal;text-align:le=
ft;text-decoration:none;text-indent:0px;text-transform:none;white-space:nor=
mal;word-spacing:0px"><span>The behavior, use and definition of observer_pt=
r are not changed. =C2=A0</span></span></span></div><span class=3D""><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 this still doesn&#39;t handle pe=
rfect forwarding. Not unless it is the caller of the function who wraps the=
 parameter in an `observer_ptr`.</div></div></blockquote><div><br></div></s=
pan><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"cour=
ier 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-inde=
nt: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;background-color:transparent">A_vi=
ew(const A* pa) : _p(pa) {}</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-=
style:normal;font-variant:normal;font-weight:400;text-decoration:none;word-=
spacing:0px;display:inline!important;white-space:normal;float:none;backgrou=
nd-color:transparent"><span>A_view(const A&amp; a) : _p(&amp;a) {}</span></=
span></font></div><div><font face=3D"courier new,monospace">=C2=A0 <span st=
yle=3D"text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:=
0px;letter-spacing:normal;font-size:13px;font-variant:normal;word-spacing:0=
px;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;le=
tter-spacing:normal;font-size:13px;font-variant:normal;word-spacing:0px;dis=
play:inline;white-space:normal;float:none;background-color:transparent"><sp=
an>A_view(A&amp;&amp; a) : _p(&amp;a) {}</span></span></span></font></div><=
div><span style=3D"text-align:left;color:rgb(34,34,34);text-transform:none;=
text-indent:0px;letter-spacing:normal;font-size:13px;font-variant:normal;wo=
rd-spacing:0px;display:inline!important;white-space:normal;float:none;backg=
round-color:transparent"><span style=3D"margin:0px;padding:0px;border:0px r=
gb(34,34,34);text-align:left;color:rgb(34,34,34);text-transform:none;text-i=
ndent:0px;letter-spacing:normal;font-size:13px;font-variant:normal;word-spa=
cing:0px;display:inline;white-space:normal;float:none;background-color:tran=
sparent"><span><font face=3D"courier new,monospace"><br></font></span></spa=
n></span></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-spacing:normal;font-size:13px;font-variant:normal;word-spacing:0px;=
display:inline!important;white-space:normal;float:none;background-color:tra=
nsparent"><span style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);te=
xt-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;lette=
r-spacing:normal;font-size:13px;font-variant:normal;word-spacing:0px;displa=
y:inline;white-space:normal;float:none;background-color:transparent"><span>=
observer_ptr&lt;const A&gt; _p;</span><b></b></span></span></font></div><di=
v><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">obse=
rver_ptr will monitor addressof(*_p) for ~A() call. The scope of monitoring=
 is ~<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:normal;fon=
t-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;disp=
lay:inline!important;white-space:normal;float:none;background-color:transpa=
rent">observer_ptr() or release() call.</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"><br></span></font></div><div><font face=3D"arial,san=
s-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:normal=
;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;=
display:inline!important;white-space:normal;float:none;background-color:tra=
nsparent">Copies of=C2=A0<span style=3D"margin:0px;padding:0px;border:0px r=
gb(34,34,34);text-align:left;color:rgb(34,34,34);text-transform:none;text-i=
ndent:0px;letter-spacing:normal;font-size:13px;font-style:normal;font-varia=
nt:normal;font-weight:400;text-decoration:none;word-spacing:0px;display:inl=
ine;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"><font face=3D"arial,sans-seri=
f">observer_ptr still monitor the same address, but with a different scope =
- their dtor, release or reset.</font></span></span></span></span></font><f=
ont face=3D"arial,sans-serif"><span style=3D"text-align:left;color:rgb(34,3=
4,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-size:1=
3px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:n=
one;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-size:13px;font-style:normal;font=
-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;displ=
ay:inline;white-space:normal;float:none;background-color:transparent"><span=
 style=3D"background-color:transparent;border-bottom-color:rgb(34,34,34);bo=
rder-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);di=
splay:inline;float:none;font-size:13px;font-style:normal;font-variant:norma=
l;font-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;m=
argin-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;word-spacing:0px"><span style=3D=
"background-color:transparent;border-bottom-color:rgb(34,34,34);border-bott=
om-style:none;border-bottom-width:0px;border-left-color:rgb(34,34,34);borde=
r-left-style:none;border-left-width:0px;border-right-color:rgb(34,34,34);bo=
rder-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:inl=
ine;float:none;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"></span></span></span></=
span></font></div><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-s=
pacing:normal;font-size:13px;font-style:normal;font-variant:normal;font-wei=
ght:400;text-decoration:none;word-spacing:0px;display:inline!important;whit=
e-space:normal;float:none;background-color:transparent"><span style=3D"marg=
in: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:13=
px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:no=
ne;word-spacing:0px;display:inline;white-space:normal;float:none;background=
-color:transparent"><span style=3D"background-color:transparent;border-bott=
om-color:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0px;bor=
der-left-color:rgb(34,34,34);border-left-style:none;border-left-width:0px;b=
order-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:0=
px;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-bot=
tom: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-dec=
oration:none;text-indent:0px;text-transform:none;white-space:normal;word-sp=
acing: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:0px;border-rig=
ht-color:rgb(34,34,34);border-right-style:none;border-right-width:0px;borde=
r-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;fo=
nt-variant:normal;font-weight:400;letter-spacing:normal;margin-bottom:0px;m=
argin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:0px;padding-l=
eft:0px;padding-right:0px;padding-top:0px;text-align:left;text-decoration:n=
one;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px=
"><br></span></span></span></span></font></div><font face=3D"arial,sans-ser=
if"><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:normal;font=
-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;displ=
ay:inline!important;white-space:normal;float:none;background-color:transpar=
ent"><span style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-al=
ign:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spa=
cing:normal;font-size:13px;font-style:normal;font-variant:normal;font-weigh=
t:400;text-decoration:none;word-spacing:0px;display:inline;white-space:norm=
al;float:none;background-color:transparent"><span style=3D"background-color=
:transparent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;bor=
der-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;fo=
nt-size:13px;font-style:normal;font-variant:normal;font-weight:400;letter-s=
pacing: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;wh=
ite-space:normal;word-spacing:0px"><span style=3D"background-color:transpar=
ent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-botto=
m-width:0px;border-left-color:rgb(34,34,34);border-left-style:none;border-l=
eft-width:0px;border-right-color:rgb(34,34,34);border-right-style:none;bord=
er-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;bor=
der-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size:1=
3px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:no=
rmal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padd=
ing-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-alig=
n:left;text-decoration:none;text-indent:0px;text-transform:none;white-space=
:normal;word-spacing:0px"><div><br></div></span></span></span></span></font=
><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;fon=
t-size:13px;font-style:normal;font-variant:normal;font-weight:400;text-deco=
ration:none;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-style:nor=
mal;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0=
px;display:inline;white-space:normal;float:none;background-color:transparen=
t"><span style=3D"background-color:transparent;border-bottom-color:rgb(34,3=
4,34);border-bottom-style:none;border-bottom-width:0px;border-left-color:rg=
b(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-co=
lor:rgb(34,34,34);border-top-style:none;border-top-width:0px;color:rgb(34,3=
4,34);display:inline;float:none;font-size:13px;font-style:normal;font-varia=
nt:normal;font-weight:400;letter-spacing:normal;margin-bottom:0px;margin-le=
ft: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;word-spacing:0px"><span =
style=3D"background-color:transparent;border-bottom-color:rgb(34,34,34);bor=
der-bottom-style:none;border-bottom-width:0px;border-left-color:rgb(34,34,3=
4);border-left-style:none;border-left-width:0px;border-right-color:rgb(34,3=
4,34);border-right-style:none;border-right-width:0px;border-top-color:rgb(3=
4,34,34);border-top-style:none;border-top-width:0px;color:rgb(34,34,34);dis=
play:inline;float:none;font-size:13px;font-style:normal;font-variant:normal=
;font-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;ma=
rgin-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-r=
ight:0px;padding-top:0px;text-align:left;text-decoration:none;text-indent:0=
px;text-transform:none;white-space:normal;word-spacing:0px">That is a major=
 difference from lifetime extension - we can have many-to-one mapping witho=
ut any semantic or implementation problems.=C2=A0<span style=3D"display:inl=
ine!important;float:none;background-color:transparent;color:rgb(34,34,34);f=
ont-family:arial,sans-serif;font-size:13px;font-style:normal;font-variant:n=
ormal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration=
:none;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0=
px">Lifetime extension does not allow copies of a view/ref to extend with t=
he lifetime of the object.</span></span></span></span></span></font></div><=
div><font face=3D"arial,sans-serif"><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"><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-size:13px;font-style:norma=
l;font-variant:normal;font-weight:400;text-decoration: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-width:0px;border-left-color:rgb(=
34,34,34);border-left-style:none;border-left-width:0px;border-right-color:r=
gb(34,34,34);border-right-style:none;border-right-width:0px;border-top-colo=
r: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;pa=
dding-right:0px;padding-top:0px;text-align:left;text-decoration:none;text-i=
ndent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span st=
yle=3D"background-color:transparent;border-bottom-color:rgb(34,34,34);borde=
r-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);displ=
ay:inline;float:none;font-size:13px;font-style:normal;font-variant:normal;f=
ont-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;marg=
in-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-rig=
ht:0px;padding-top:0px;text-align:left;text-decoration:none;text-indent:0px=
;text-transform:none;white-space:normal;word-spacing:0px">We are also not l=
imited to initialization only - the monitoring can (re)start at the call of=
 reset() instead on constructor call only. Lifetime extension deals with in=
itialization exclusively.=C2=A0</span></span></span></span></font></div><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"><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);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!impor=
tant;white-space:normal;float:none;background-color:transparent"><span styl=
e=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;fon=
t-size:13px;font-style:normal;font-variant:normal;font-weight:400;text-deco=
ration:none;word-spacing:0px;display:inline;white-space:normal;float:none;b=
ackground-color:transparent"><span style=3D"background-color:transparent;bo=
rder-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-widt=
h:0px;border-left-color:rgb(34,34,34);border-left-style:none;border-left-wi=
dth:0px;border-right-color:rgb(34,34,34);border-right-style:none;border-rig=
ht-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;border-to=
p-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13px;fo=
nt-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal;m=
argin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bo=
ttom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:left=
;text-decoration:none;text-indent:0px;text-transform:none;white-space:norma=
l;word-spacing:0px"><span style=3D"background-color:transparent;border-bott=
om-color:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0px;bor=
der-left-color:rgb(34,34,34);border-left-style:none;border-left-width:0px;b=
order-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:0=
px;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-bot=
tom: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-dec=
oration:none;text-indent:0px;text-transform:none;white-space:normal;word-sp=
acing:0px"><br></span></span></span></span></font></div><div>How can perfec=
t forwarding interfere in all this?=C2=A0</div><div><br></div><div><br></di=
v><div><font face=3D"courier new,monospace"><span class=3D"">template&lt;ty=
pename T, typename ...Args&gt;<br></span>auto init(Args&amp;&amp;... arg)<b=
r>{<br>=C2=A0 return T(std::forward&lt;Args&gt;(arg)...); //&lt; observer_p=
tr starts monitoring &amp;arg<br>}<br><br>int main()<br>{ <br>=C2=A0 auto v=
 =3D init&lt;A_view&gt;(A{}); //&lt; both A_view and A allocated. A_view us=
able before the &#39;;&#39; when ~A is called<br>}</font></div><div><font f=
ace=3D"courier new"><br></font></div><div>If copy elision does not kick-in =
nothing changes - copy is safe and defined, lifetime of A is the same.</div=
><div><br></div><div>If we pass arguments and create A in init() instead ( =
<font face=3D"courier new,monospace">return</font>=C2=A0 <span style=3D"dis=
play:inline!important;float:none;background-color:transparent;color:rgb(34,=
34,34);font-family:courier new,monospace;font-size:13px;font-style:normal;f=
ont-variant:normal;font-weight:400;letter-spacing:normal;text-align:left;te=
xt-decoration:none;text-indent:0px;text-transform:none;white-space:normal;w=
ord-spacing:0px">T(A(std::forward&lt;Args&gt;(arg)...<wbr>)); </span>), the=
n the <font face=3D"courier new,monospace">observer_ptr </font>is still cre=
ated with a valid address, </div><div>however, after 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,monospace">&#39;;&#39;.=C2=
=A0</font></div><div><b></b><i></i><u></u><sub></sub><sup></sup><strike></s=
trike><font face=3D"courier new,monospace"><br></font></div><div>If both th=
ere is no elision and A is created when initializing T inside init, then th=
e returned view can be created from a dangling view.=C2=A0</div><div>We cou=
ld allow views from dangling views to be created, however=C2=A0<span style=
=3D"display:inline!important;float:none;background-color:transparent;color:=
rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helvetica&quot;,sans-seri=
f;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;lett=
er-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text=
-transform:none;white-space:normal;word-spacing:0px">no dtor will be monito=
red and</span> all uses of the view will be illegal until destroyed/reset/r=
elease-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><d=
iv><font face=3D"arial,sans-serif"><b><i><br></i></b></font></div><div>=C2=
=A0</div></div><span class=3D"">

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4fa792ec-1f51-4357-a65a-2ce3c10c60c0%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/4fa7=
92ec-1f51-4357-<wbr>a65a-2ce3c10c60c0%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></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/CALvx3hYQHFXi5eRrcdCGEqWj-n4w4NKYDpRx=
4G_U16i%2B2VS5nQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYQHFXi5e=
RrcdCGEqWj-n4w4NKYDpRx4G_U16i%2B2VS5nQ%40mail.gmail.com</a>.<br />

--001a114411780b9ee7056336617d--

.
