220 32508 <1c728d4e-7f8e-4528-23a7-5a9ba198ebbc@honermann.net> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Tom Honermann <tom@honermann.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Allow Structured Binding Outside of Variable Declaration
Date: Tue, 16 May 2017 19:43:21 -0400
Lines: 186
Approved: news@gmane.org
Message-ID: <1c728d4e-7f8e-4528-23a7-5a9ba198ebbc@honermann.net>
References: <e02d79e8-7d80-4614-bd25-e73fb43dad9d@isocpp.org>
 <CAFk2RUbf5skMEcsLd_hUiZrib2bGCvyrJbgsx9LV-rXaj=fBZw@mail.gmail.com>
 <CAFk2RUbgg7UMc_mFGKQZF7-PVVbEDsdoZoXL46oyxr+PLRTfvw@mail.gmail.com>
 <08ff73f1-6989-393e-ee4e-8158af2e7bed@honermann.net>
 <CAFk2RUaBhq7KVukgRMvqBMuBiBwZmCf+xZpD9jRtBberFoU2Rg@mail.gmail.com>
 <c70b0cd6-fa3e-d215-3fef-06eb231ed3cd@honermann.net>
 <CAFk2RUbiUZ4n_mXdBUTGEZSsh5C=Mf0hKbKu76PKzCCWnZfrgA@mail.gmail.com>
 <d184a83a-4f99-a8d2-6bba-1b8aeedd797c@honermann.net>
 <20170516164245.GA16348@fukushima.lysator.liu.se>
 <ffcb4ca3-5fb8-41b4-8b38-cfd287148cd5@honermann.net>
 <CAFk2RUY1AYOen-Rb8n6yzc1jsOiydbUCUDqLdKMPyiyiHnnO4w@mail.gmail.com>
 <c0bf3a06-53e5-3411-0967-b167da5d0dcd@honermann.net>
 <CAFk2RUYaNuKM=xhLTP_ZE97KvRUAJybUhaoFAmT+V_-7P3t1Mg@mail.gmail.com>
 <dedf6bf1-599c-400e-a392-ee7bc8be0afb@isocpp.org>
 <586c2633-4586-12d8-35ae-75ebab176ff8@honermann.net>
 <CADvuK0JFhG1anzEmHLg5+mhiLcHGU+31PRY=gWPhSuG0Ejd5zw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------8C013CBA4CC1370326F81341"
X-Trace: blaine.gmane.org 1494978206 32670 195.159.176.226 (16 May 2017 23:43:26 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 16 May 2017 23:43:26 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.2.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDBNXSHG6UDBBGU553EAKGQEKFSYHJQ@isocpp.org Wed May 17 01:43:19 2017
Return-path: <std-proposals+bncBDBNXSHG6UDBBGU553EAKGQEKFSYHJQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f197.google.com ([209.85.192.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDBNXSHG6UDBBGU553EAKGQEKFSYHJQ@isocpp.org>)
	id 1dAm7a-0008Hi-Ro
	for gclcip-std-proposals@m.gmane.org; Wed, 17 May 2017 01:43:19 +0200
Original-Received: by mail-pf0-f197.google.com with SMTP id a66sf136661101pfl.6
        for <gclcip-std-proposals@m.gmane.org>; Tue, 16 May 2017 16:43:24 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1494978204; cv=pass;
        d=google.com; s=arc-20160816;
        b=fgc8j/755viDExEYSlEOpEUDJpU7mBfcuiRRFMz+Tl3a9pj+CmBOUa2kxDMrjhxjQX
         9IuTGV5LBq3zwRIJ+MKlMv2tWJdMQkdY7svE4VnxSo5WXK4McD+kx4Ztscr8zsXWR5kv
         W+tHN6uGdxyCupQddsLNUdsPFueuV5O5R27bsORqtlRpRWlqzYGUkA1JeG4x29HTRk+Z
         j2Qf3RAXh0cOBm8GLH4yYLKM2Kk1kxC9madqy9fs5Q+uxPKaiVlrbz9KspkQaq86EEdV
         MmEmQDuG+snV+ve9XNZpB/hnrQ6OAlGBnksUvwFDth3hSq4Sri9i7ZNCUvYnjnnf5r80
         XIPw==
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:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:to:subject
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=SdOEO2JPHI05Kl0QQw2GJP9f37jPbOBqfe9UEvt+0B4=;
        b=RMGYmKBshtXZh4F1gwZ578Kvrgjykeye8r7a15AtyBEw2noCqeqiTdznVh+6zOCbfq
         pbt52KlGYNezTXMo70qWXM9uj+p2qi0pumdxNxPdNx+NX8HEXoW05F3E467vkkhEkOzJ
         n7JDkUzssoFJGEbGu4sswlJWZTKi3ykfRIXZR9WEWIZPgqw3NqfS4G+tFfyuQWrrBsyu
         pRBLWf4+nqN10nXL2MqTVB/6/p86bhdl6Ec3xYu/cyXKvqVHCamAqOIr3Xiigy4JuoMV
         WZGNqVRZicqURHv8BqJqbAoetoKQZOgJt3awBg9HXz5csHut3kKyMj4ejCJ3zObKJAWX
         OO7A==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=neutral (google.com: 108.166.43.83 is neither permitted nor denied by best guess record for domain of tom@honermann.net) smtp.mailfrom=tom@honermann.net
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-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=SdOEO2JPHI05Kl0QQw2GJP9f37jPbOBqfe9UEvt+0B4=;
        b=sLcytpo5fsK5/00H7V3unqX2OaYcGjA2ae5eDSSngw3hy70NmWwMPKjRgQlnGEfBZl
         Sb34N6IHR8KvDD6VjJuJHVPFLSNO9Lp/QsOpILMmzSlgoXrGQc2C8rlfogZMqQ+z1ttW
         ryCnJxn6uipSOknJLFH/F8olP+zGFBdGn9Li9owgbjkJFvvK/xITx1DHj8BaMBTwtOi1
         4uzxkYxhLEvIISgemsBCwH0129H5wwY9505hAac1tWbjvJCQf0OCNGsC2xKRPFdSuqmB
         7y6X9/rdvKDbmZrmqSMeeLI6kIvgFLXhsl2ywDsZNeBprnHmWFg6tUd/w8BnJ97nttrb
         ROAw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-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=SdOEO2JPHI05Kl0QQw2GJP9f37jPbOBqfe9UEvt+0B4=;
        b=TIdyouGhZL2lCerU59/7oaBnpQP5Cw2k+xMFylX5mPk9EEP+JLTs9rfZTVSJ513pBv
         rGmxTGM1BSQmu+OcNLaZ0ZqvxmqwchtzI7glbUR5Nc9K4aTVIcAC2VB8RrvWCW9y9ER+
         nG2F80XOf6TlpG9GqUCrxSqh2DneFRu7ygYnC5YJrGBAtWrU6UdOoR+w6IdfX7qUKmrx
         at5OO8ATzlM+pKaNGRYjOVVgOv3OYxVYw/b6ZyhpBYaeJlTs/9yNBxpzjvklY2RL++z3
         BW+zDpotYLgR9ZKI7xz6+eV+V9bewhoDWQbXBVp2jlx34l39vL/+WSn4ynKguGuV4rM0
         45zQ==
X-Gm-Message-State: AODbwcA8uBftYm3sR7kXhqI6iDRvJoBSAJGch8Sswx1InxG1QlBamgJf
	PRUQNsl9uPipeg==
X-Received: by 10.99.110.73 with SMTP id j70mr264541pgc.143.1494978204003;
        Tue, 16 May 2017 16:43:24 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.108.74 with SMTP id w71ls849992itb.8.gmail; Tue, 16 May
 2017 16:43:22 -0700 (PDT)
X-Received: by 10.107.35.13 with SMTP id j13mr507132ioj.75.1494978202630;
        Tue, 16 May 2017 16:43:22 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1494978202; cv=none;
        d=google.com; s=arc-20160816;
        b=PVsfFrN2BfZoUckM2whTE3GuYkJtBy6BI/06jjDHtupOLfLRuYm8p64FBVVfdw9FWg
         7Cu0zBkyOwpbgG3OroJRI/f7WPFRVXbOL35TYqpZJWVRyKhDbFaB+XQ+VXiIxRTDMUm5
         1opFXvB94qazHPfLU9YrQ+l5u37CEiyQCgsBzPVikC1SGjLNr8ReMXN4Ns33Rjkc1yDn
         pBL/epXOE//TrW76ljWiTIs78HLju+8ahr+KFHlNtYjC0vy9Wov+ghj9AcJQDbfAmgZR
         qlxaR6j9m5uXQ04SusI/q8/2OVcgipDy6h4f14d9oydJYEty9D7UAK52K3quviafkyyQ
         fuIQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=in-reply-to:mime-version:user-agent:date:message-id:from:references
         :to:subject:arc-authentication-results;
        bh=w8utSuwMgVoAJE4t0l5FiMmBuLju7mumVLJQs5etBow=;
        b=jvi9imcgdmL6vZpirunWq1yWdVpMWOZXOQCxTSZyEiRjSrlxL0Klnv+FPKGStQDoAP
         mhBAs8yoTtQFbPdueH6P9nf8B/XAAbeSPuJD9HlrjN8jf5opWozvZp9E4nYw1ER0lXUm
         f7zXUoR/x4hJy3N7B+yo/ht56Km3Q/gXhfAC3+KEj/IsiHDB8xWOqpHcEDt1kVdC1kDc
         TjwvU4czFaw1peG7iGSUEHN96LqbpjUHIsU6fMb6RvCuW1PtX4/irMDDUwUqOC+OMU4/
         paAfqUyjiSJNmzC7SUw/Mn7MpYWXv8rOYVJUDl90pe80luvdC9/zAMzLhFsKgyY54aVu
         dzWw==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: 108.166.43.83 is neither permitted nor denied by best guess record for domain of tom@honermann.net) smtp.mailfrom=tom@honermann.net
Original-Received: from smtp83.ord1c.emailsrvr.com (smtp83.ord1c.emailsrvr.com. [108.166.43.83])
        by mx.google.com with ESMTPS id q144si331743iod.126.2017.05.16.16.43.22
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 16 May 2017 16:43:22 -0700 (PDT)
Received-SPF: neutral (google.com: 108.166.43.83 is neither permitted nor denied by best guess record for domain of tom@honermann.net) client-ip=108.166.43.83;
Original-Received: from smtp11.relay.ord1c.emailsrvr.com (localhost [127.0.0.1])
	by smtp11.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 388C3A00CC
	for <std-proposals@isocpp.org>; Tue, 16 May 2017 19:43:22 -0400 (EDT)
X-Auth-ID: tom@honermann.net
Original-Received: by smtp11.relay.ord1c.emailsrvr.com (Authenticated sender: tom-AT-honermann.net) with ESMTPSA id 065ECA01A1
	for <std-proposals@isocpp.org>; Tue, 16 May 2017 19:43:21 -0400 (EDT)
X-Sender-Id: tom@honermann.net
Original-Received: from [192.168.1.7] (pool-173-53-30-126.rcmdva.fios.verizon.net [173.53.30.126])
	(using TLSv1.2 with cipher DHE-RSA-AES128-SHA)
	by 0.0.0.0:587 (trex/5.7.12);
	Tue, 16 May 2017 19:43:22 -0400
In-Reply-To: <CADvuK0JFhG1anzEmHLg5+mhiLcHGU+31PRY=gWPhSuG0Ejd5zw@mail.gmail.com>
X-Original-Sender: tom@honermann.net
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 108.166.43.83 is neither permitted nor denied by best guess
 record for domain of tom@honermann.net) smtp.mailfrom=tom@honermann.net
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:32508
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32508>

This is a multi-part message in MIME format.
--------------8C013CBA4CC1370326F81341
Content-Type: text/plain; charset="UTF-8"; format=flowed

On 05/16/2017 06:41 PM, Arthur O'Dwyer wrote:
> On Tue, May 16, 2017 at 2:53 PM, Tom Honermann <tom@honermann.net 
> <mailto:tom@honermann.net>> wrote:
>
>     On 05/16/2017 05:12 PM, Bengt Gustafsson wrote:
>>     Why not let a variable declaration inside a structured binding be
>>     a variable declaration?
>     I eluded to this being a sound design in an earlier reply.  Is
>     there good motivation for being able to declare a variable rather
>     than a binding?  I find the current design highly motivating
>     specifically because a binding is effectively an alias.
>
>
> Speaking of "being able to declare a variable instead of a binding", 
> this morning I ran across this example due to Tony van Eerd:
>
> struct Foo {
>     int x = 0;
>     std::string str = "world";
>     ~Foo() { std::cout << str; }
> };
>
> int main() {
>     auto [i, s] = Foo();
>     std::cout << "hello ";
>     s = "structured bindings";
>     // Foo's destructor prints "hello structured bindings"!
> }
>
> ...which is the nail in the coffin of "ever using C++17 structured 
> bindings in production code" AFAIC.

Do you find the fact that the following code exhibits the same behavior 
surprising?

int main() {
     auto foo = Foo();
     std::cout << "hello ";
     foo.s = "structured bindings";
     // Foo's destructor prints "hello structured bindings"!
}

Tom.

-- 
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/1c728d4e-7f8e-4528-23a7-5a9ba198ebbc%40honermann.net.

--------------8C013CBA4CC1370326F81341
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">On 05/16/2017 06:41 PM, Arthur O'Dwyer
      wrote:<br>
    </div>
    <blockquote
cite=3D"mid:CADvuK0JFhG1anzEmHLg5+mhiLcHGU+31PRY=3DgWPhSuG0Ejd5zw@mail.gmai=
l.com"
      type=3D"cite">
      <div dir=3D"ltr">On Tue, May 16, 2017 at 2:53 PM, Tom Honermann <span
          dir=3D"ltr">&lt;<a moz-do-not-send=3D"true"
            href=3D"mailto:tom@honermann.net" target=3D"_blank">tom@honerma=
nn.net</a>&gt;</span>
        wrote:<br>
        <div class=3D"gmail_extra">
          <div class=3D"gmail_quote">
            <blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-=
style:solid;padding-left:1ex">
              <div bgcolor=3D"#FFFFFF"><span class=3D"gmail-">
                  <div
                    class=3D"gmail-m_-6536589000383708425moz-cite-prefix">O=
n
                    05/16/2017 05:12 PM, Bengt Gustafsson wrote:<br>
                  </div>
                  <blockquote type=3D"cite">
                    <div dir=3D"ltr">Why not let a variable declaration
                      inside a structured binding be a variable
                      declaration?</div>
                  </blockquote>
                </span> I eluded to this being a sound design in an
                earlier reply.=C2=A0 Is there good motivation for being abl=
e
                to declare a variable rather than a binding?=C2=A0 I find t=
he
                current design highly motivating specifically because a
                binding is effectively an alias.</div>
            </blockquote>
            <div><br>
            </div>
            <div>Speaking of "being able to declare a variable instead
              of a binding", this morning I ran across this example due
              to Tony van Eerd:</div>
            <div><br>
            </div>
            <div>
              <div><font face=3D"monospace, monospace">struct Foo {</font><=
/div>
              <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 int x =
=3D 0;</font></div>
              <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 std::s=
tring str
                  =3D "world";</font></div>
              <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 ~Foo()=
 {
                  std::cout &lt;&lt; str; }</font></div>
              <div><font face=3D"monospace, monospace">};</font></div>
              <div><font face=3D"monospace, monospace"><br>
                </font></div>
              <div><font face=3D"monospace, monospace">int main() {</font><=
/div>
              <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 auto [=
i, s] =3D
                  Foo();</font></div>
              <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 std::c=
out
                  &lt;&lt; "hello ";</font></div>
              <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 s =3D =
"structured
                  bindings";</font></div>
              <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 // Foo=
's
                  destructor prints "hello structured bindings"!</font></di=
v>
              <div><font face=3D"monospace, monospace">}</font></div>
            </div>
            <div><br>
            </div>
            <div>...which is the nail in the coffin of "ever using C++17
              structured bindings in production code" AFAIC.</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Do you find the fact that the following code exhibits the same
    behavior surprising?<br>
    <br>
    <div><font face=3D"monospace, monospace">int main() {</font></div>
    <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 auto foo =3D Foo=
();</font></div>
    <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 std::cout &lt;&l=
t; "hello
        ";</font></div>
    <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 foo.s =3D "struc=
tured
        bindings";</font></div>
    <div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 // Foo's destruc=
tor
        prints "hello structured bindings"!</font></div>
    <div><font face=3D"monospace, monospace">}</font></div>
    <br>
    Tom.<br>
  </body>
</html>

<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/1c728d4e-7f8e-4528-23a7-5a9ba198ebbc%=
40honermann.net?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goog=
le.com/a/isocpp.org/d/msgid/std-proposals/1c728d4e-7f8e-4528-23a7-5a9ba198e=
bbc%40honermann.net</a>.<br />

--------------8C013CBA4CC1370326F81341--

.
