220 33043 <CADvuK0JfnhrRMS1VM1MGz73kgrYRHoRdG_=T6N9Z+ohBSoD5=w@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 10:32:01 -0700
Lines: 103
Approved: news@gmane.org
Message-ID: <CADvuK0JfnhrRMS1VM1MGz73kgrYRHoRdG_=T6N9Z+ohBSoD5=w@mail.gmail.com>
References: <6e23864f-827a-4bdb-89de-a60d8f5be993@isocpp.org>
 <c44c5d09-9124-488f-aa92-f9ab59797268@isocpp.org> <c039c5e5-13d0-4052-89f7-b2af50f1e0fc@isocpp.org>
 <0dd0a5ae-5fc2-020f-73a9-f5c7959fed0f@gmail.com> <cebea1ab-9c29-4c7d-acea-9d3ff6b4062c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="94eb2c1cca7887ffe8055330cb00"
X-Trace: blaine.gmane.org 1498843927 2959 195.159.176.226 (30 Jun 2017 17:32:07 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 30 Jun 2017 17:32:07 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQIJFFW2ZICRUBHBAUKUU@isocpp.org Fri Jun 30 19:31:59 2017
Return-path: <std-proposals+bncBDLZJYWNDQIJFFW2ZICRUBHBAUKUU@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f70.google.com ([74.125.82.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDLZJYWNDQIJFFW2ZICRUBHBAUKUU@isocpp.org>)
	id 1dQzlt-0000MM-TS
	for gclcip-std-proposals@m.gmane.org; Fri, 30 Jun 2017 19:31:57 +0200
Original-Received: by mail-wm0-f70.google.com with SMTP id 12sf8443246wmn.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 30 Jun 2017 10:32:03 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1498843923; cv=pass;
        d=google.com; s=arc-20160816;
        b=lqUnE7vINhtwC/RpFS/A4Z3Q3vPUaS42Xa/VF0D4I4yLYunG3PxitTBGORiaMOv//E
         /S2g2HFjjgq2/W9AP8fRMtvHgZWsVNuSpWeeq2+1G4PaaLNQ98HcnivIUYg7Ks9eZZuo
         vJbx6lJzJJ7R+7NvYdWe9ehbRucXgOmaVDwgPUK8u3z3s4Rm7khy1Z0orhzeX7ki1IEn
         gYanPBbmT9aJQR/vmXk323nGekjdXvlkNWe19fau+EkqNe9UI77E9vmPst3XLTf52QKF
         LFCtedRiAtCN6WJD+bWLkJJ1q1zl/rfBYJoUfdL38UcUuXr/awiTJMFF0yrYF0meQg+7
         ReHg==
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=90o+I9nlpCQRTYVd2gWUIpOPwjDatejiD/61fkZ9n3Q=;
        b=E4/D7zdrRgpZeZAeLxBa5fSa7x5kcopRG6W9+Pib80jaWe8tuWSBnKc0N8XB7kx3B5
         n1oBBjRxWzOX1w+FAHeXUKYqtCGzyC/KmC9NWZJ2W/bJKxC/fEhp6ROoe328iKvhm1AO
         AlOBbMDl7CjbNuNZ4pMBaPOgatCSEmLB3PVLgAHAkrqb/69lZtvyrCOgzWvBH5dXrXjV
         Lp/FKGPn4/AkgbORZIsPJSPS6wTQjEaTGxi21Odwu9eYmyaOPT7eZu8Lhg7NxOwclw2p
         aqRtKvG0+xeoFZHzLTaLPv520/9Sb8/GzCALXvOQUOau/zbpNIOAMysYelHOxgDn9spO
         /hKg==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=IdWOg22G;
       spf=pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::230 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=90o+I9nlpCQRTYVd2gWUIpOPwjDatejiD/61fkZ9n3Q=;
        b=Fxl5NFdCD9LCyTBTlWess+F6I7bTLGf9P+dWTklS4OPwW1x8PYMV/Zxhbku9gvbFto
         NIlMnVJoAdYiTN3sqgDPfm2Bz2DH0tz48CHyJP04lH1fXk4jTfQ63GIy76suFVT9zsCN
         nC91sUyhre8UoeIiB2x3k0TnLZLJRC5OFwP0/tWgZqznXE3ElnmsfQIQe61SxKCzK+s2
         TjIhveGsfJl8/Gvc+LDwlx86hUJED0B1SowonqnM+sG1CJYiOrHrufIPaM4NPsD52wfy
         JIsEMOcNLo1nxp36XBGzpGeDywklbROwuE43adt7PtfEE6X6MU4QrgJ1HdosJ0VjLw8S
         kC4Q==
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=90o+I9nlpCQRTYVd2gWUIpOPwjDatejiD/61fkZ9n3Q=;
        b=MY17xcBHnmF8sKhJb/kvg4CboptTheGAixWuXZBNaA3UZ4gHG7cOog+oNFsbPQMg9/
         CXwKR1IQ9I6WX60ZWze7knFdqOH6S1AAbqmaifez8zgHvFo1erz3nuHbx75EIiWJy9eO
         Y409q7+ZpVekA4eE3yC4W5zU3TFj4aYNC5zsQJvLbJHfkn15MnFOQkfBVizNnGsWAvi8
         U7vhXRbWFWPae2d8n6mu4SFuiKuJvuShqhieKKMRcH0dAyUdqNGKfxTuQI+OoC26+WQ2
         /nPSe+Dpyymbau9Q8Qv+3ot6ZN9GjODgHSRbrJdE7nNNhoHXK+zsCywEpE2DVcHvirys
         RbTQ==
X-Gm-Message-State: AKS2vOwbIoq4TECBG/tlwtEfpvxS961MwagsXuq4EB1TL/F/gVnF5DWb
	MI6HAlYMhaJSUmXd
X-Received: by 10.223.175.81 with SMTP id z75mr4376549wrc.15.1498843923406;
        Fri, 30 Jun 2017 10:32:03 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.45.15 with SMTP id t15ls783974wmt.6.gmail; Fri, 30 Jun 2017
 10:32:02 -0700 (PDT)
X-Received: by 10.223.146.161 with SMTP id 30mr29778258wrn.164.1498843922242;
        Fri, 30 Jun 2017 10:32:02 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1498843922; cv=none;
        d=google.com; s=arc-20160816;
        b=eL+2YKAbnMaeAYRz3ppzDlH4gy4Nogp3zDdXDtqP3N+5FbHfQW+JI3QLfLQVBOg2DB
         R6BwrhlIWnU2lUTMfRi2VMc6yK3mC+6hQ4+BadTmRnlC63Lkak5XSD786Q90E5sWo9l7
         W/Cu/Hy6jPoAGzM/T77k5eJ3k0LyWWYETUt75ziZMN44lIqtb4iAmSO4VuVPyIuD25cc
         Kqn6sbaUIB80OhdZXRS4F9+pO/khhU+wMdhDxRB9d6JhrpgZt6pUQthjBNQBHFB/fdjh
         e8nqPDS5EByAxQv2Ra8JFCBPBHZBM7sDFjsQ/uD7EqXZqvds15Rs3E5EX0p2W3pMaBRr
         +mhQ==
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=KrRvgdQAs455ySD3aBaiHNV/N/v2xJOCshWzx+BwSSQ=;
        b=DQ76OXIYpqfdTi9Law3hfHxCUJZ3/IWbArFnrq3U2o1ZRgQgLsMfLw/74n9JMUm/mF
         b6qIILPKQSWHNXBI8rJp7Jm7oSaF5r3/aullyIQHLSDdBNgXWL2de3kjcGotxVoPQQfE
         woUFpnUBdQ+d2p3mIR8hXY9suWHay80fRolo95iNiWZXpWc+ZE8OPKULH5Al1zuYkn4p
         GQiR4N3oOpWbm8Uwmh0vY+JzUAEun0e1Vkb4eEjE6ItZ4u2r2vJT2Ud/WqVMD4olBaOT
         FDYUpwvAaVeuubSb4iZUMnJMnupTUDaYlf1Dr8i0epZrN/lyLiDMo8XA7dt/u/3++q73
         Md0w==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=IdWOg22G;
       spf=pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::230 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-x230.google.com (mail-wm0-x230.google.com. [2a00:1450:400c:c09::230])
        by mx.google.com with ESMTPS id m79si6629404wmg.165.2017.06.30.10.32.02
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 30 Jun 2017 10:32:02 -0700 (PDT)
Received-SPF: pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::230 as permitted sender) client-ip=2a00:1450:400c:c09::230;
Original-Received: by mail-wm0-x230.google.com with SMTP id i127so53029742wma.0
        for <std-proposals@isocpp.org>; Fri, 30 Jun 2017 10:32:02 -0700 (PDT)
X-Received: by 10.80.195.21 with SMTP id a21mr6046683edb.144.1498843921773;
 Fri, 30 Jun 2017 10:32:01 -0700 (PDT)
Original-Received: by 10.80.173.204 with HTTP; Fri, 30 Jun 2017 10:32:01 -0700 (PDT)
In-Reply-To: <cebea1ab-9c29-4c7d-acea-9d3ff6b4062c@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=IdWOg22G;       spf=pass (google.com: domain of
 arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::230 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:33043
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33043>

--94eb2c1cca7887ffe8055330cb00
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, Jun 30, 2017 at 10:24 AM, <inkwizytoryankes@gmail.com> wrote:

>
> 16 because you need full byte object in optional otherwise you will get
> `std::vector<bool>` mk2.
>

I hate vector<bool> as much as you do, I promise. :)  The analogy doesn't
work here. vector<bool> is terrible because it *purports* to expose
accessors returning bool& but its in-memory representation doesn't contain
a full-byte bool anywhere, so it has to cheat and use proxy iterators and
just generally mess things up.

In the case of std::optional<std::optional<bool>>, it purports to expose
accessors returning bool& *if and only if* both the outer and inner
optionals are engaged. When either optional is disengaged, the bool member
does not exist and therefore there is no need to keep it around in memory
(in fact, we are required by the Standard to destroy it[1]). Which means
that we have a whole unused byte to play around with. We just need to make
sure that when the optionals *are* engaged, the bool really truly exists =
=E2=80=94
and I do make sure of that.

Notice that I left out the case where "both optionals are disengaged."
That's because no such state exists. When the outer optional is
disengaged, *there
is no inner optional* =E2=80=94 the inner optional is not in any state at a=
ll =E2=80=94 it
has been destroyed, and will not reappear until you engage the outer
optional again.

*An optional<T> which is disengaged does not hold a T.*

=E2=80=93Arthur

[1] modulo the as-if rule

--=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/CADvuK0JfnhrRMS1VM1MGz73kgrYRHoRdG_%3DT6N9Z%2Boh=
BSoD5%3Dw%40mail.gmail.com.

--94eb2c1cca7887ffe8055330cb00
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Fri, Jun 30, 2017 at 10:24 AM,  <span dir=3D"ltr">&lt;<=
a href=3D"mailto:inkwizytoryankes@gmail.com" target=3D"_blank">inkwizytorya=
nkes@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div cla=
ss=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"><div><di=
v class=3D"h5"><br></div></div><div>16 because you need full byte object in=
 optional otherwise you will get `std::vector&lt;bool&gt;` mk2.<br></div></=
div></blockquote><div><br></div><div>I hate vector&lt;bool&gt; as much as y=
ou do, I promise. :) =C2=A0The analogy doesn&#39;t work here. vector&lt;boo=
l&gt; is terrible because it <i>purports</i> to expose accessors returning =
bool&amp; but its in-memory representation doesn&#39;t contain a full-byte =
bool anywhere, so it has to cheat and use proxy iterators and just generall=
y mess things up.</div><div><br></div><div>In the case of std::optional&lt;=
std::optional&lt;bool&gt;&gt;, it purports to expose accessors returning bo=
ol&amp; <i><b>if and only if</b></i> both the outer and inner optionals are=
 engaged. When either optional is disengaged, the bool member does not exis=
t and therefore there is no need to keep it around in memory (in fact, we a=
re required by the Standard to destroy it[1]). Which means that we have a w=
hole unused byte to play around with. We just need to make sure that when t=
he optionals <i>are</i> engaged, the bool really truly exists =E2=80=94 and=
 I do make sure of that.</div><div><br></div><div>Notice that I left out th=
e case where &quot;both optionals are disengaged.&quot; That&#39;s because =
no such state exists. When the outer optional is disengaged, <i>there is no=
 inner optional</i> =E2=80=94 the inner optional is not in any state at all=
 =E2=80=94 it has been destroyed, and will not reappear until you engage th=
e outer optional again.</div><div><br></div><div><b>An optional&lt;T&gt; wh=
ich is disengaged does not hold a T.</b></div><div><br></div><div>=E2=80=93=
Arthur</div><div><br></div><div>[1] modulo the as-if rule</div><div><br></d=
iv></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/CADvuK0JfnhrRMS1VM1MGz73kgrYRHoRdG_%3=
DT6N9Z%2BohBSoD5%3Dw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0Jfnh=
rRMS1VM1MGz73kgrYRHoRdG_%3DT6N9Z%2BohBSoD5%3Dw%40mail.gmail.com</a>.<br />

--94eb2c1cca7887ffe8055330cb00--

.
