220 40763 <CAANG=kVVCnTpCRkFaG2X0=jYaDvQLDm7SDQT3WkTxXHktTXn0g@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: shared_ptr and unique_ptr should both implicitly
 convert to observer_ptr
Date: Fri, 26 Oct 2018 11:00:28 +0300
Lines: 141
Approved: news@gmane.org
Message-ID: <CAANG=kVVCnTpCRkFaG2X0=jYaDvQLDm7SDQT3WkTxXHktTXn0g@mail.gmail.com>
References: <81a04b52-e5cd-4543-86c5-5a0068f9647b@isocpp.org>
 <CAOHCbiuqHGogymYhCxDGmQWVPegmZQjoOy738k9Ey6J=arCe7A@mail.gmail.com>
 <CAFk2RUZABEZobZ7aR6=iQU_yX-+m_7jhCJ4BwVMaCxDPj+cTJw@mail.gmail.com>
 <CAOHCbiv2HYLVs0s3M338aRdmGi5q-f-s3SA4jy1fLqMP0gmSmg@mail.gmail.com>
 <CAFk2RUYRmaYmc12EfaUiBHiO1_t-2z2fE7NvdnJvkcWEhCoNSg@mail.gmail.com>
 <CAOHCbivLHMKjNH8WQ9KU9Rwb=Ga=r2SZS=Mb0gGEHgExAGYtJg@mail.gmail.com>
 <a965b8a7-9b3c-45e0-9cb5-736079ca4313@isocpp.org> <CAFk2RUYcVuz2WpDoC3rFOjpBvk85R1Wt2APhBdGJ2znETywmEA@mail.gmail.com>
 <CANiq72mByDkQB3C0nfUegzYRD30T3B15HMw2_yiQvBPUH7D2+w@mail.gmail.com>
 <CAFk2RUYo3TZ-3Ngnid5ypgksLAshNXNf2GvFT-KEoHnDmCYNxg@mail.gmail.com>
 <CANiq72=0kNTCSmRZ_gGHzoi_FhWMm_LspH5-b6cuXXOES+cKQQ@mail.gmail.com>
 <CAFk2RUYXCZ14eSO3VGMxWg+7A+Wsa=1ogzqzGfL76bZWB77nfA@mail.gmail.com>
 <CANiq72n3rMda2GydaGyGkZgda8=0PfWqNEjRRMwuk-1DZiuoPA@mail.gmail.com>
 <CAFk2RUYdibw_0w+O0Cy49ZTBKq4ibo=pP2AocEWE_LE_zr+x4g@mail.gmail.com> <CANiq72kOHDe28rHekVQ9Ov+OuXZ2wMnH-CQ__PRD4+nB_pLAEw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="00000000000085e26b05791d1d63"
X-Trace: blaine.gmane.org 1540540716 22167 195.159.176.226 (26 Oct 2018 07:58:36 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 26 Oct 2018 07:58:36 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDRYVJ6TVYBRBKMTZPPAKGQEG6HWRAY@isocpp.org Fri Oct 26 09:58:32 2018
Return-path: <std-proposals+bncBDRYVJ6TVYBRBKMTZPPAKGQEG6HWRAY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lj1-f198.google.com ([209.85.208.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDRYVJ6TVYBRBKMTZPPAKGQEG6HWRAY@isocpp.org>)
	id 1gFx0q-0005fr-0D
	for gclcip-std-proposals@m.gmane.org; Fri, 26 Oct 2018 09:58:32 +0200
Original-Received: by mail-lj1-f198.google.com with SMTP id s14-v6sf92650lji.2
        for <gclcip-std-proposals@m.gmane.org>; Fri, 26 Oct 2018 01:00:42 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1540540842; cv=pass;
        d=google.com; s=arc-20160816;
        b=wZ4eV0/TqDRAroIGfQ+Lq5jtfUooD/GipO/yWh68zLcCQPyMnPIjjN0EUGU8Xqwhpt
         rogIKwJzDK8DG3l53EdSbcVG8iEGKG+bErATHYgIFB8ctvEaC5RfhsXfl3H7QSuEm7yf
         Q0d43tjY0cTBl9Ue0JGUiFK1hHZnOzwnKw6RgbNg43yW6ckRm3USJ85Yy6MyTOyOf21i
         xOkyI3LtooNsq3NMAgu++gVgzA7JXjqozKsNy1GF8etD4epNG5XsDFLSJqGV/hXBoeRR
         sFt/0px0G35RD+gfdnRYz9+nQ7ho/f77+whRGxq1wRRBQuCDKmfDspSIPvDfB1Kt3pAi
         XKTg==
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:in-reply-to:references:mime-version:dkim-signature;
        bh=C3wJkYDtow/UMbg/K8+Qkcrq6Ttt4XseaYJ3OiI2FeQ=;
        b=T3/eP3vg+OfClD6bRlFHE3cOUYj37yxa5ch7DxAo3gD/bqy4RGe55L1WrldoIEbcWc
         7PkH0CZfnC0K4IzBZs6GxLrjgPBLIwEezK8hcWXUT89Z1t1y+SB/TH6JXjClG76GNXlZ
         sD+gIGIuzG+MXBvqXfQ2Zg2c8cuGQ3ZB4n7la3OH6orMdFZL99/StZMN1PZB27njO7Ub
         10qHwYj7AnUdNmeY4q1S0uOkue8y7EbKdelvIAPaMNAy56E1o/pRG3fpNm/MEjZOKUsa
         Bdx4MM97GHUdcpoc71ZraRYujr0fsBfBRs0TwAPEQoTlkyabsdN+EX+/Z70QFxkFVas6
         BJSw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=U4B8MdLW;
       spf=pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=gasper.azman@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE 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:references:in-reply-to: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=C3wJkYDtow/UMbg/K8+Qkcrq6Ttt4XseaYJ3OiI2FeQ=;
        b=rO61xdY49+91eWVonx5W2iNp02Tv7yZgnCCX2FhihSOMOheviaOwWTgu0JbdS6NbuH
         2Kkj8xbit/zJQoDuy0si+66MnazQ3DjxVsHO4/cvkVCF1SUBnoU3LIp2RrIEwF8iYP3w
         Lh8kOhRh8Fx6cl6JTTLoR+Q9YWpcUGd6q+9CuOfDSHhOsFDL65375A9aqeM4Ud58/WYv
         PmmEReR5wb7Ey/zH8j5VVHM2uOkYbJ+zKyt/0zjsl4Ikjz5Ban5bWT8p77LJItnJC3Pw
         Zk5EGu/O4JyMz+ttoBYYipWTV6Jhwyb/M/z/lOlg+lA0eOcceAtBI7Vn1zNAVR+Zsayg
         nceQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to: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=C3wJkYDtow/UMbg/K8+Qkcrq6Ttt4XseaYJ3OiI2FeQ=;
        b=BvyZw8oTwVmjM/0DvWqcjTbYegiaYRGW8qjvfi7gtYZvZ1OlLjeEkWIf5GBR/cjLNS
         MgpM3SlamrAXXiael280mOY2XQnw9p1qEaKrmptYn5lgTUQ9pP9WFXHzZkPEY8E+w/WK
         5EjOph0x59T8I2Z8Q4AkpLpEyW5xDmC/hQR6c60aZ4rN1LatiHctvT2M/FrkbUOyCaoX
         FSFC/7ph3qJo6VE23BR8641Jp1e70aOKrszetHzsZ9NW+RZHrsPwmXf7DGmuq7cmdQCm
         uNuonrDCQ/OiITFN7+wKWlTDguU0XGi/cXJZso18vBZ+wgv1lFIu1Dsc0cr51sJ1h+Md
         R4PQ==
X-Gm-Message-State: AGRZ1gLn22f8CiqNC2gL1lqBe72d5q2NzUIpLG259UuuCRQrT7/mk0oW
	ATKFpt/q4K9Ges+kqwwC/q/ucw==
X-Google-Smtp-Source: AJdET5ex4S0ugfhHRk9UQuLgQoTpGlzSsMyf8eQ5P+mw8FIRmlgsQ0/pHY6Dv6Yk8B9dG5REoy66ig==
X-Received: by 2002:a2e:9245:: with SMTP id v5-v6mr232511ljg.20.1540540842720;
        Fri, 26 Oct 2018 01:00:42 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a19:3804:: with SMTP id f4-v6ls75537lfa.7.gmail; Fri, 26 Oct
 2018 01:00:40 -0700 (PDT)
X-Received: by 2002:a19:6f0a:: with SMTP id k10-v6mr1626971lfc.8.1540540840680;
        Fri, 26 Oct 2018 01:00:40 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1540540840; cv=none;
        d=google.com; s=arc-20160816;
        b=VnMJKF46oMZagmv0ppDZftzcrEJFtoVIyddlOYTy1RVag4OlNcwHVlkMk3MZNj8Lpn
         ffUubsNoTLil9LamtwWytv39/wAd5ME9OgsE5u8DDQ07qoVR3dEJxOE+WGgT5wz8eulg
         LrsU9ydp5b2ddfukokFSt51FrPAjrRZN8mvPDOeeraIsGnhTMhgvDZteiFSlB4J41AVj
         WNm7YEz9sV1PWIYIFhmb67KrVN9yg1LHrnMszS3vOrSmBdb1f6NvKMECfNZ96xqSr5SU
         HiCBWSvaLMArermHZTvye6AZl7zQDWR+UCNJx466ZDR7sZlSdQc9xEA6qM5KQKqWd6Z8
         CoPQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature;
        bh=KeqVRSrkW8rPwMn16rE8fIqV34rY6zcFMxWKCpRUKTs=;
        b=KZRH0EOqOoup1UaViAtR4yzC5rDt5EfYRcxYB+WxtgYYK3INF9OItYlK0ohFwe8iVS
         R7HJPKkhUV0jpqE2uRpVy1FYggFz02rz6mXUc+R/H2oADiYQEVXeSMnoUqVdmBR+m1w+
         v5gnqJvPJG2xy4wXinW0TcvMjkdm3QZlB8EMeEUkjuT4jmzcuQVqz3MtbRxHyYuJqUSR
         zLFHbhfAD0t6lUhM3ymZoj5mmUxYJQEUHcoyY+5p3X7BdFFZSK2/Ha466YkYXlXVbPWd
         cbw/1OjOfmRAU0RU9Zf46ehgcV1FVTOkRSYuvojw6wvmktB7EGbWFTcNbY/ZCApyQhzI
         uO2A==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=U4B8MdLW;
       spf=pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=gasper.azman@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE 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 x14-v6sor6756484ljh.27.2018.10.26.01.00.40
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Fri, 26 Oct 2018 01:00:40 -0700 (PDT)
Received-SPF: pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a2e:81d3:: with SMTP id s19-v6mr1433579ljg.138.1540540839877;
 Fri, 26 Oct 2018 01:00:39 -0700 (PDT)
In-Reply-To: <CANiq72kOHDe28rHekVQ9Ov+OuXZ2wMnH-CQ__PRD4+nB_pLAEw@mail.gmail.com>
X-Original-Sender: gasper.azman@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=U4B8MdLW;       spf=pass
 (google.com: domain of gasper.azman@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=gasper.azman@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE 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:40763
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40763>

--00000000000085e26b05791d1d63
Content-Type: text/plain; charset="UTF-8"

Differences:

void foo(T* x);

observer_ptr<T> p:
optional<T&> opt;

foo(p.get());
foo(opt?&*opt:nullptr);

plus, the hashing on observer pointers is the hash of the pointer value,
and in the case where I want a set of unique optional object references I
have to specify my own hash on the `&*opt`s again.

Basically, despite the fact that there is a bijection, they are not
equivalent in usage. We can very well have both, with good guidelines on
when to use each, and perhaps two-way conversions to boot.

G


On Fri, Oct 26, 2018 at 10:40 AM Miguel Ojeda <
miguel.ojeda.sandonis@gmail.com> wrote:

> On Thu, Oct 25, 2018 at 10:59 PM Ville Voutilainen
> <ville.voutilainen@gmail.com> wrote:
> >
> > On Thu, 25 Oct 2018 at 23:31, Miguel Ojeda
> > <miguel.ojeda.sandonis@gmail.com> wrote:
> >
> > I can always get the pointer value from an observer_ptr. I can't get a
> > value from an optional<T&> when it has none.
>
> [Forgot to reply to this]
>
> That, again, is *no* difference. You can create a two-way function
> that maps empty optional<T&> to a nullptr. The only cases which would
> be impossible to represent with an optional<T&> are all the
> non-nullptr & non-valid pointers/addresses, which is what I said in
> the beginning and Tony replied to. Again: the nullptr case is not one
> of those.
>
> Cheers,
> Miguel
>
> --
> 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/CANiq72kOHDe28rHekVQ9Ov%2BOuXZ2wMnH-CQ__PRD4%2BnB_pLAEw%40mail.gmail.com
> .
>

-- 
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/CAANG%3DkVVCnTpCRkFaG2X0%3DjYaDvQLDm7SDQT3WkTxXHktTXn0g%40mail.gmail.com.

--00000000000085e26b05791d1d63
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Differences:<div><br></div><div>void foo(T* x);</div><div>=
<br></div><div>observer_ptr&lt;T&gt; p:</div><div>optional&lt;T&amp;&gt; op=
t;</div><div><br></div><div>foo(p.get());</div><div>foo(opt?&amp;*opt:nullp=
tr);</div><div><br></div><div>plus, the hashing on observer pointers is the=
 hash of the pointer value, and in the case where I want a set of unique op=
tional object references I have to specify my own hash on the `&amp;*opt`s =
again.</div><div><br></div><div>Basically, despite the fact that there is a=
 bijection, they are not equivalent in usage. We can very well have both, w=
ith good guidelines on when to use each, and perhaps two-way conversions to=
 boot.</div><div><br></div><div>G</div><div><br></div></div><br><div class=
=3D"gmail_quote"><div dir=3D"ltr">On Fri, Oct 26, 2018 at 10:40 AM Miguel O=
jeda &lt;<a href=3D"mailto:miguel.ojeda.sandonis@gmail.com">miguel.ojeda.sa=
ndonis@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On =
Thu, Oct 25, 2018 at 10:59 PM Ville Voutilainen<br>
&lt;<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank">ville.=
voutilainen@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; On Thu, 25 Oct 2018 at 23:31, Miguel Ojeda<br>
&gt; &lt;<a href=3D"mailto:miguel.ojeda.sandonis@gmail.com" target=3D"_blan=
k">miguel.ojeda.sandonis@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; I can always get the pointer value from an observer_ptr. I can&#39;t g=
et a<br>
&gt; value from an optional&lt;T&amp;&gt; when it has none.<br>
<br>
[Forgot to reply to this]<br>
<br>
That, again, is *no* difference. You can create a two-way function<br>
that maps empty optional&lt;T&amp;&gt; to a nullptr. The only cases which w=
ould<br>
be impossible to represent with an optional&lt;T&amp;&gt; are all the<br>
non-nullptr &amp; non-valid pointers/addresses, which is what I said in<br>
the beginning and Tony replied to. Again: the nullptr case is not one<br>
of those.<br>
<br>
Cheers,<br>
Miguel<br>
<br>
-- <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%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CANiq72kOHDe28rHekVQ9Ov%2BOuXZ2wMnH-C=
Q__PRD4%2BnB_pLAEw%40mail.gmail.com" rel=3D"noreferrer" target=3D"_blank">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANiq72kOHDe28r=
HekVQ9Ov%2BOuXZ2wMnH-CQ__PRD4%2BnB_pLAEw%40mail.gmail.com</a>.<br>
</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/CAANG%3DkVVCnTpCRkFaG2X0%3DjYaDvQLDm7=
SDQT3WkTxXHktTXn0g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkVVCn=
TpCRkFaG2X0%3DjYaDvQLDm7SDQT3WkTxXHktTXn0g%40mail.gmail.com</a>.<br />

--00000000000085e26b05791d1d63--

.
