220 32494 <c0bf3a06-53e5-3411-0967-b167da5d0dcd@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 14:57:17 -0400
Lines: 62
Approved: news@gmane.org
Message-ID: <c0bf3a06-53e5-3411-0967-b167da5d0dcd@honermann.net>
References: <e02d79e8-7d80-4614-bd25-e73fb43dad9d@isocpp.org>
 <10b21241-b683-44d5-82ce-90681b2643a4@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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1494961043 22974 195.159.176.226 (16 May 2017 18:57:23 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 16 May 2017 18:57:23 +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+bncBDBNXSHG6UDBBD4X5XEAKGQEUOUWEMA@isocpp.org Tue May 16 20:57:18 2017
Return-path: <std-proposals+bncBDBNXSHG6UDBBD4X5XEAKGQEUOUWEMA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f70.google.com ([74.125.83.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDBNXSHG6UDBBD4X5XEAKGQEUOUWEMA@isocpp.org>)
	id 1dAhek-0005mi-Jl
	for gclcip-std-proposals@m.gmane.org; Tue, 16 May 2017 20:57:14 +0200
Original-Received: by mail-pg0-f70.google.com with SMTP id z6sf120835599pgc.13
        for <gclcip-std-proposals@m.gmane.org>; Tue, 16 May 2017 11:57:20 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1494961039; cv=pass;
        d=google.com; s=arc-20160816;
        b=q31lpXNGWgvnYSMV9DzdORgtlCXk34h+D4jwGB6PH0LAwZKBYu6EQwDwVTntKgSjDe
         HUsqmC5tQHcCaoMYiVzWY1tQxeckj9aIerl7QVtIpY4Js+UX16+nMz98NFTrVmMm9u1j
         OMzAZC1MPAI8O7ynjp8WOnhfe+rAAj7+3Uli8PN350/yUW/R0B1FMe6k6e9MCkp1rPQy
         0YDe0U5CHs3Wi22VrmM0Wm4dM9GYQTxmLB/qml8BDdwaejV3+DFAyZDTGcqQM3KdKt5r
         WLoSfV/8ka88FVlzF5TECttpa/mKFucY/DGo68WpwzE5N6/sbWZGQDnCK/HNabzkoP8z
         B7fQ==
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=Hu+k1ejqOeseyrjUFtWRsDqXZ//LJ4o0u76IM2mxTaY=;
        b=cqpmx9+qY5/iqxtNjqg1QcfqpkWJfAvnpbIKWrxNf4TJ0/OMVaNgIFNBCzufEGZZ8q
         Spds0q31J4Wha8IfPiZmlJrv1xXauKMzUpXzVsvCVn14LQx64fyzqxnbl1+RdVhYlN0x
         BbDzbnMrAouOYFrbkf2phgwhqB8JApIkWVWJgSsiLQ8GnY9eCMRmYLCu/Lda9c0bB0Fv
         Jh/kc1psdL2cqlIxIdjaBP7D+6QM+LgxjwXdfRJ3MFoYR2wjmVkvELaBhWN4zlOo6zJO
         aPW9T1W8uOZZYRR0pitDuSgh4n0niuJLSu73Y6tCTGXtcfudGWxwC6LUpvZViI81S2kF
         6yAA==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=neutral (google.com: 67.192.241.131 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=Hu+k1ejqOeseyrjUFtWRsDqXZ//LJ4o0u76IM2mxTaY=;
        b=Mus13TtXMn90d3R86qI+mHJj8PHl89JoA6JNCLMpG3T2mtn+9Y1rm1+cv9B5YNYcy8
         CJvHLOn0xdNFvuStDp4d5BEMKaGAQwWebpTWfKzTMVl+JJWaL9gsdpAxuOfGcAlYm6BR
         QsORLkBZJraa56zFAZuTFpyFK6Ir68Jr7gvboIaJXRry83OCC/Kh7m1xyc/VCtl7irdb
         hHCi+x1SS+i5FrezW9YxcB7aNJvBegBe5NJxgoT8IyVG5a053LJZN+mkAmDS/c+3Z995
         jijvL0VjondWJaGz64KTjAi+1GkieYjdjZ+IRckzsDyTfElwqWurZZh5h/Bvi5/vLBj6
         6Lkw==
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=Hu+k1ejqOeseyrjUFtWRsDqXZ//LJ4o0u76IM2mxTaY=;
        b=Vsq/EWim4XGEv6xRW1VsQed04rx72SkLw3B/XUQ2a45N/CQBeLDy6i/4lv3EhWINP0
         HhJnPv6cm8mScN9BnxNK+wyesJ3xocUQC8BdNucDYdINh/dA3qnNf4WDN3Fwjpht+qq8
         5iKXIwNpjSCpRmbdopbpq81C5rg4+V//F7g56KF8ToNuxTpDV+1rpfTUCx5AaLglojUY
         d4XE+Pm0CHhNwfhU5BwxJ/zzhLcLvf2E1wDN/BG3IpuW/p1K5c0k0bvYiBgbDtxwvjUj
         xyUAXFODUZHNwiXVWBmMA69GK2PWCUSTYfmEQ9na9AIeZEAiXmu1xWimLj5F6wV6g//U
         aKxQ==
X-Gm-Message-State: AODbwcC8FJ/BhxIq0CUx5amzDa876maeJwdx219WwxgXTwm/wS3MoA2o
	W2LrVlW3Tq6aHQ==
X-Received: by 10.99.100.134 with SMTP id y128mr6230021pgb.124.1494961039635;
        Tue, 16 May 2017 11:57:19 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.4.20 with SMTP id 20ls2164069otc.41.gmail; Tue, 16 May
 2017 11:57:18 -0700 (PDT)
X-Received: by 10.157.5.178 with SMTP id 47mr6127203otd.39.1494961038847;
        Tue, 16 May 2017 11:57:18 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1494961038; cv=none;
        d=google.com; s=arc-20160816;
        b=d5KvqPH3ZS4qgrKpMi45WMuhD2zp0lIKnadQmaO1XsKupkAcg3HNEU6ei4fqscE23N
         CLdIZEYky/R0okAtjht17R50QK3LF8SXfmTG073VGI/FrN4IvOSBRg2T++z66nEdjrKj
         opeGa3WtQjvTE/8wicYHDZFdbzT2RO/BZUDU36OigVvsh+1QMWrZe3UJWr+47YwDOnzk
         E3uWop3RzY8GBjJQSC0WbEZtoFV52+JseYYi8qgqvX16UayJ1dy7Xvgu4rG0iZRimeyj
         bXEMd7siAZhwQiElen7imBrNWxo5p9IWT04fnVdKX3L7KIyjsj+3cTpEU/eDReIcQM1f
         5PIQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:in-reply-to:mime-version:user-agent:date
         :message-id:from:references:to:subject:arc-authentication-results;
        bh=68BfndogoZKxR0A6744cAqtJCkWEJ0wMYHHRPao4d+Q=;
        b=F2EbqF90ucAaAAMfeMwXWqXSCPnpqFb90EzfolmyCNfTiBB0J1rdo5p6gPqrSaLb/G
         23tLOwwQblenoUdtKdcaSzKPjgqfWRmPd3YzCP1nKALKeU7P+ss/cXCsZst0pSjnBEGk
         hpa+qDbpAL/Qe+zVsKxCLXu68yZoRfvHHk2PyGh34mjScDCPQFmVMYy76Iu8pNrqX+YF
         HhlLBu+7WHcR8CwK5Lo1CSYxZ6SLrsMC+BpWLWCKW4Gdgfschvl5O9PDHKBc0jJ6Ja2d
         X6Wn28oF5UsoLLY5EeE4tMnMXa+1oF79Ib/87VLOqZvr9aaW0M9SFitxgyJfY2pD7WR7
         VGKA==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: 67.192.241.131 is neither permitted nor denied by best guess record for domain of tom@honermann.net) smtp.mailfrom=tom@honermann.net
Original-Received: from smtp131.dfw.emailsrvr.com (smtp131.dfw.emailsrvr.com. [67.192.241.131])
        by mx.google.com with ESMTPS id k13si55645oih.87.2017.05.16.11.57.18
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 16 May 2017 11:57:18 -0700 (PDT)
Received-SPF: neutral (google.com: 67.192.241.131 is neither permitted nor denied by best guess record for domain of tom@honermann.net) client-ip=67.192.241.131;
Original-Received: from smtp21.relay.dfw1a.emailsrvr.com (localhost [127.0.0.1])
	by smtp21.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 67C1E401EB
	for <std-proposals@isocpp.org>; Tue, 16 May 2017 14:57:18 -0400 (EDT)
X-Auth-ID: tom@honermann.net
Original-Received: by smtp21.relay.dfw1a.emailsrvr.com (Authenticated sender: tom-AT-honermann.net) with ESMTPSA id 303B84018D
	for <std-proposals@isocpp.org>; Tue, 16 May 2017 14:57:18 -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 14:57:18 -0400
In-Reply-To: <CAFk2RUY1AYOen-Rb8n6yzc1jsOiydbUCUDqLdKMPyiyiHnnO4w@mail.gmail.com>
X-Original-Sender: tom@honermann.net
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 67.192.241.131 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:32494
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32494>

On 05/16/2017 01:35 PM, Ville Voutilainen wrote:
> On 16 May 2017 at 20:01, Tom Honermann <tom@honermann.net> wrote:
>>> What is wrong with the good old way?
>>>
>>> auto [SomeType x, =k->Key] = parseKey();
>>
>> There is the question of what happens if the decomposed type of the matching
>> element is not reference compatible with type 'SomeType'. Ill-formed?  Does
>> 'x' change from being a structured binding to a variable of the declared
>> type?  If so, are conversions performed? What type is decltype(x) and does
> Why on earth would it change from being a structured binding to something else?
Nicol's response nicely explains this perspective; if one expects 
'<type-specifier> <identifier>' to declare a variable as it does, I 
think, everywhere else that syntax is currently allowed, then use of 
that syntax here to declare something other than a variable is 
surprising.  An argument that this syntax, rather than declaring a 
structured binding, declare a variable initialized by the decomposed 
element, is sound.  I'm not saying we need or should have that 
capability (to declare a variable instead of a binding), just that it is 
arguably the semantic behavior one might expect; exactly as Nicol described.
>
>> it depend on the type of the matching element?  A syntax that indicates a
>> type constraint (which is, I think, what is desired regardless of the syntax
>> used) rather than a variable declaration avoids these questions.
>
> Funny, such "type constraints" were something I always considered to
> be an integral and fundamental
> part of variable declarations.
They certainly are; a variable declaration necessarily identifies a type 
(in C++).  But a type constraint doesn't necessarily imply a variable 
declaration.
>   I don't write
>
> auto x = foo(); static_assert(is_same_v<decltype(x), int>);
>
> but for some reason it's been suggested that I should do that for
> structured bindings, conveniently forgetting
> that then I will need to put that "type constraint" far far away from
> my structured bindings, like into a for-loop body
> when the structured binding is in the loop header.
>
I'm not following this.  We're discussing:

for (auto [Type x] : c) {}

vs

for (auto [x -> Type] : c) {}

Unless you were responding to questions elsewhere regarding the 
motivation to be able to express a type constraint at all?  I agree with 
you that some means to constrain the type in the structured binding 
declaration is desirable.

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/c0bf3a06-53e5-3411-0967-b167da5d0dcd%40honermann.net.

.
