220 33047 <CADvuK0JexAJBZn1LsAPcZnabCJ4pz3J3HUahGeX_FEW8HBPCtw@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: std::optional - support for sentinel values
Date: Fri, 30 Jun 2017 12:42:25 -0700
Lines: 114
Approved: news@gmane.org
Message-ID: <CADvuK0JexAJBZn1LsAPcZnabCJ4pz3J3HUahGeX_FEW8HBPCtw@mail.gmail.com>
References: <6e23864f-827a-4bdb-89de-a60d8f5be993@isocpp.org>
 <c44c5d09-9124-488f-aa92-f9ab59797268@isocpp.org> <2991b2b2-2f62-42e2-83d1-f42dae9c32c1@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="94eb2c0de474e2fb670553329d12"
X-Trace: blaine.gmane.org 1498851752 11455 195.159.176.226 (30 Jun 2017 19:42:32 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 30 Jun 2017 19:42:32 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQIKHU62ZICRUBCDGYKZQ@isocpp.org Fri Jun 30 21:42:28 2017
Return-path: <std-proposals+bncBDLZJYWNDQIKHU62ZICRUBCDGYKZQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f71.google.com ([209.85.215.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDLZJYWNDQIKHU62ZICRUBCDGYKZQ@isocpp.org>)
	id 1dR1o7-0002Tf-Ef
	for gclcip-std-proposals@m.gmane.org; Fri, 30 Jun 2017 21:42:23 +0200
Original-Received: by mail-lf0-f71.google.com with SMTP id l200sf30315787lfb.6
        for <gclcip-std-proposals@m.gmane.org>; Fri, 30 Jun 2017 12:42:29 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1498851749; cv=pass;
        d=google.com; s=arc-20160816;
        b=UzxIlrzu2YDddnDYJhdF1kMxTfJfpoq2y2S8NWNwBa2hKczETEkc7CxMPctO2Hu/CJ
         kLPNPpFIV7mGQzhINJGfOdIiVJq2wbhm9v0YMKxffxlsls2Lc5M3JK1Z86UpXsMiAvbc
         d7mj8OY2ahSQ0PgnVtdP0x+4PHnhx6F3WTXp0Pe/0zCTLUByIBFx0Hd0ahlilOgCQQzN
         IEJWbIuqRVmGNpSNEnnlUWOIMQluSTv1x2PTXCsEB7Qgnl8mjkjp6dSow+zUrGc0XNvU
         ypX93PHuKv1rWuhtGLVXZv/uMAoYE1to2ZJgkaVOV1crCBDlFXtly0irIOWeMigARvpy
         6FlA==
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=u9mrtMy4LBHAiYTHY8DBZXLpaZ77uUV0apktonPCv2I=;
        b=Or1gJt7lGiGJlTmhcO3EGR1KZp+urMaCIMeso6D7p6xJ/llMwfTy24qC8HMnbLaVdC
         isLoWFZrjSUPQLm+AEFgfqlm2BqoWIE3+SFLH9gpw4354sUBqN5cVIhR8OA7oJMa4iZ9
         mzsfv9tT+1+N2dofBk0yCymAbW0Neyq8UpaZ+nop7LofcsTAjMA8uk3oWRLeT5dO6Qak
         ie6Cz4ViQI6ebxhErQ+jQm7ZXrDNCLyVwsWmduSSO3biThKAryw8K/3wlrqaCn193x+V
         FAFcU4ksLJpVT5gRRHRmYJOXrJOoIeE66CS/BsQsYC9kgAb/jUVEkzN+VmQYOgD+iXNF
         9uFw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=PgWBpSuL;
       spf=pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::232 as permitted sender) smtp.mailfrom=arthur.j.odwyer@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=u9mrtMy4LBHAiYTHY8DBZXLpaZ77uUV0apktonPCv2I=;
        b=yHK5iFBBiObhVQoaj2QQDXJTqQ6jw+7SgZSO6aKA5IYFXopQGGVNDEmmvQZT+uyfGd
         y4j7/7I8oFk0T56ynAbxynUpwOv71Ea3/EpNM1rAMkn+GgkFZL9d5Ru6FiCMki/UoGkN
         v7HKJq5vBaHDzXr0lchkwn6gRrzUv2Xqv8lIh1T56iTq+SjX31ERaJVkY+epB9sPeV6D
         2oziuaBunKaLzIo3up9lV5QM+q60rVZvXXIDozBTyL+2XDoEeG8sOw9q2Irs9tGzxEa6
         LsZFRV2jWMsRnKYaHwwS9xP02ClB/8+s9GKH5Qsm8nHdcytXCizwdmNnivmTDkN4n87+
         jHXA==
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=u9mrtMy4LBHAiYTHY8DBZXLpaZ77uUV0apktonPCv2I=;
        b=UKhxjVBi1YTZgsxHupqkD2f3dkcYoar7NUOZgpPdYOAG85OLukrLyjf2DzQqNGLQ6Q
         RqH8JPs6zoS+3DW5lA/EE+D0LwXRHXivuhZ5M306U9sTKbGIxW5uvWuArGhnk4mSevt+
         4T1MKFczcE0hp5Qblw24XO0LBSB2ZMBPNP1JJTY/upwbZByUcjXbKqEQKO68mnVPfFfO
         4Q+Mz1vQDgdDy+xJG9174GYPjk4bYqik4Rh/5PTGxoeFbwFMfyhIEIP1jJ+swfen+h6X
         3hHmQOBhk/mDmvBxXgGt9EaJmXwF4K4WQsz5e3MeYn2XX9n2E/7bFKzA3RTkcjnyNPtm
         L2MQ==
X-Gm-Message-State: AIVw110YwKZFhrAxRNLqM6Lg7v/WKoOjD0roJY6czd2jxEj82OnvZFux
	xZ7TMXFvtoQ71F+M
X-Received: by 10.25.153.74 with SMTP id b71mr980189lfe.14.1498851748755;
        Fri, 30 Jun 2017 12:42:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.63.87 with SMTP id m84ls813964wma.3.gmail; Fri, 30 Jun 2017
 12:42:26 -0700 (PDT)
X-Received: by 10.223.163.92 with SMTP id d28mr27525441wrb.98.1498851746871;
        Fri, 30 Jun 2017 12:42:26 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1498851746; cv=none;
        d=google.com; s=arc-20160816;
        b=lOCdiFHhChTa1ny7Gv6kKe1q2m5trxHYPaXWSnJnsYpHhHOi/FxBGyoAwpwdq26jp5
         vchQe4IzyXbw+5h5dYKL3FY873FoiZhBXRDvishkXWLhokNXSW8HUphp3sjRl26+2eTv
         djGfxCfX7hKB65ik94zo1uxw46A1fOeJ0otN/R++6PpBXJGMw6CvakVfyUrgCHLrOuKj
         RCId1o7/GwKpY5lD8di9tSmD+zmY9EKRcBCinAdL/abkApMg2NP9d8f3UzVjv+/tx5pq
         KEACl99fQxaMWqUzPoh0fsFtY9AYfrOEl4gluZIpa5s6nDHYK2A6AmL7z1TEciVcyrGm
         /e6g==
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=OwfGz6wVWV5FNjR8M9p1Tz8vbUiP5/f1EAqFB5kK/jk=;
        b=bVyOmAP0ywc/JFyYJB60KGNR4k2Mb2ZXODWhVdTIFoYxmXT9dItZfETaD8t1r9S97i
         3YuDINAw1sulW8IGR91UTSsSMvJ0BDtZwivukmIc/4opFBsO9F8awkyellbZPVforoY7
         +oj+yTWzd4NpHv36V1g30FRBmPz7G6NwPujw/4GQnebEVvhXMNLO86OqG5yt5xsnkE5h
         Scqn9Xs4XX21OIr4YmuJXx06Z1BVwgEMXTTBsVrD6VmIGKHvTs8S0UUcOPyzwMxxxnfR
         hO670qnyDCCUoFeI9swruJkseyhdNFlSfe3371m8yYGbLW6znq1axHu5X8Qa7OiTco9J
         ILpQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=PgWBpSuL;
       spf=pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::232 as permitted sender) smtp.mailfrom=arthur.j.odwyer@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com. [2a00:1450:400c:c09::232])
        by mx.google.com with ESMTPS id z130si10824061wmb.116.2017.06.30.12.42.26
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 30 Jun 2017 12:42:26 -0700 (PDT)
Received-SPF: pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::232 as permitted sender) client-ip=2a00:1450:400c:c09::232;
Original-Received: by mail-wm0-x232.google.com with SMTP id i127so55772904wma.0
        for <std-proposals@isocpp.org>; Fri, 30 Jun 2017 12:42:26 -0700 (PDT)
X-Received: by 10.80.146.79 with SMTP id j15mr6590309eda.17.1498851745919;
 Fri, 30 Jun 2017 12:42:25 -0700 (PDT)
Original-Received: by 10.80.173.204 with HTTP; Fri, 30 Jun 2017 12:42:25 -0700 (PDT)
In-Reply-To: <2991b2b2-2f62-42e2-83d1-f42dae9c32c1@isocpp.org>
X-Original-Sender: arthur.j.odwyer@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.b=PgWBpSuL;       spf=pass (google.com: domain of
 arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::232 as permitted
 sender) smtp.mailfrom=arthur.j.odwyer@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-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:33047
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33047>

--94eb2c0de474e2fb670553329d12
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, Jun 30, 2017 at 12:28 PM, Barry Revzin <barry.revzin@gmail.com>
wrote:

>
>> This is optional<reference_wrapper<T>>.
>> As for why optional<T&> is a terrible, horrible, no-good, very bad idea,
>> please see Matt Calabrese's talk
>> <https://www.youtube.com/watch?v=3DhKIYbf1fsLw> from C++Now.
>>
>
> That's not at all the impression I got from that talk. One of the things
> he specifically mentions as a good idea is to support references for
> optional/variant, but internally wrap the references so that they behave =
as
> regular types (that is, like pointers. so operator=3D would rebind
> references, not assign through them).
>

I'll have to re-watch it, then. I would say that "an optional of a regular
type that behaves like a pointer" is a good idea, but *that* one is spelled
optional<T*>.  Notice that part of behaving like a regular type is making
sure that the semantics of operator=3D=3D match the semantics of your
copy-constructor: a copy of a value should compare =3D=3D to the original
value, and modifying the copy should not modify the original.  I'm pretty
sure Matt talks about *that* pretty extensively.

The places where we put "foo<T&>" into the standard are either places where
the rebinding question never comes up (e.g. std::promise<T&>) or places
where the rebinding question *does* come up and the answer is "oh crap,
maybe that was a bad idea" (e.g. std::tuple<T&>).  I said as much during
Matt's talk (hence why I haven't watched the video).  IMO, if C++11 had had
proper multiple-assignment, then it wouldn't have needed assign-throughable
std::tie, and if it didn't have std::tie, then it wouldn't have had
std::tuple<T&>.  For the cases where we use std::tie and
std::forward_as_tuple today, we could equally well be using a
"std::forwarding_tuple<T>" with perfect-forwarding read-through semantics
and no operator=3D at all.  But, hindsight is 20/20.

=E2=80=93Arthur

--=20
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 e=
mail 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/CADvuK0JexAJBZn1LsAPcZnabCJ4pz3J3HUahGeX_FEW8HBP=
Ctw%40mail.gmail.com.

--94eb2c0de474e2fb670553329d12
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Fri, Jun 30, 2017 at 12:28 PM, Barry Revzin <span dir=
=3D"ltr">&lt;<a href=3D"mailto:barry.revzin@gmail.com" target=3D"_blank">ba=
rry.revzin@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><d=
iv class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:=
0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><b=
lockquote 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>=
This is optional&lt;reference_wrapper&lt;T&gt;&gt;<wbr>.</div><div>As for w=
hy optional&lt;T&amp;&gt; is a terrible, horrible, no-good, very bad idea, =
please see <a href=3D"https://www.youtube.com/watch?v=3DhKIYbf1fsLw" rel=3D=
"nofollow" target=3D"_blank">Matt Calabrese&#39;s talk</a> from C++Now.</di=
v></div></blockquote><div><br></div><div>That&#39;s not at all the impressi=
on I got from that talk. One of the things he specifically mentions as a go=
od idea is to support references for optional/variant, but internally wrap =
the references so that they behave as regular types (that is, like pointers=
.. so operator=3D would rebind references, not assign through them).</div></=
div></blockquote><div><br></div><div>I&#39;ll have to re-watch it, then. I =
would say that &quot;an optional of a regular type that behaves like a poin=
ter&quot; is a good idea, but <i>that</i> one is spelled optional&lt;T*&gt;=
..=C2=A0 Notice that part of behaving like a regular type is making sure tha=
t the semantics of operator=3D=3D match the semantics of your copy-construc=
tor: a copy of a value should compare =3D=3D to the original value, and mod=
ifying the copy should not modify the original.=C2=A0 I&#39;m pretty sure M=
att talks about <i>that</i> pretty extensively.</div><div><br></div><div>Th=
e places where we put &quot;foo&lt;T&amp;&gt;&quot; into the standard are e=
ither places where the rebinding question never comes up (e.g. std::promise=
&lt;T&amp;&gt;) or places where the rebinding question <i>does</i> come up =
and the answer is &quot;oh crap, maybe that was a bad idea&quot; (e.g. std:=
:tuple&lt;T&amp;&gt;).=C2=A0 I said as much during Matt&#39;s talk (hence w=
hy I haven&#39;t watched the video).=C2=A0 IMO, if C++11 had had proper mul=
tiple-assignment, then it wouldn&#39;t have needed assign-throughable std::=
tie, and if it didn&#39;t have std::tie, then it wouldn&#39;t have had std:=
:tuple&lt;T&amp;&gt;.=C2=A0 For the cases where we use std::tie and std::fo=
rward_as_tuple today, we could equally well be using a &quot;std::forwardin=
g_tuple&lt;T&gt;&quot; with perfect-forwarding read-through semantics and n=
o operator=3D at all.=C2=A0 But, hindsight is 20/20.</div><div><br></div><d=
iv>=E2=80=93Arthur</div></div></div></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/CADvuK0JexAJBZn1LsAPcZnabCJ4pz3J3HUah=
GeX_FEW8HBPCtw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0JexAJBZn1L=
sAPcZnabCJ4pz3J3HUahGeX_FEW8HBPCtw%40mail.gmail.com</a>.<br />

--94eb2c0de474e2fb670553329d12--

.
