220 32486 <CAFk2RUaBhq7KVukgRMvqBMuBiBwZmCf+xZpD9jRtBberFoU2Rg@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Allow Structured Binding Outside of Variable Declaration
Date: Tue, 16 May 2017 17:37:09 +0300
Lines: 55
Approved: news@gmane.org
Message-ID: <CAFk2RUaBhq7KVukgRMvqBMuBiBwZmCf+xZpD9jRtBberFoU2Rg@mail.gmail.com>
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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1494945430 31888 195.159.176.226 (16 May 2017 14:37:10 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 16 May 2017 14:37:10 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5JHI7A7ALRBFU55TEAKGQEO4ROBZA@isocpp.org Tue May 16 16:37:06 2017
Return-path: <std-proposals+bncBC5JHI7A7ALRBFU55TEAKGQEO4ROBZA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f197.google.com ([209.85.223.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBFU55TEAKGQEO4ROBZA@isocpp.org>)
	id 1dAdb0-00088u-7A
	for gclcip-std-proposals@m.gmane.org; Tue, 16 May 2017 16:37:06 +0200
Original-Received: by mail-io0-f197.google.com with SMTP id j83sf101337817ioi.11
        for <gclcip-std-proposals@m.gmane.org>; Tue, 16 May 2017 07:37:12 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1494945431; cv=pass;
        d=google.com; s=arc-20160816;
        b=MfvKPSmHuDYmnLc+FLh7DMFKBzu/Z30vtXhyYOS8Z9j1tqTlmyIxEy1O01haaYBrg2
         2lV6OCqGAvEByJVvka1A9Nuc8Tn2bRliJ/X1mGku1MamKnBIZ2FXiZLe+79YdkAhLDAU
         0DxHY3hxpumnToU5Rbnil+vOL2Hc8I4lRCBArWUwnypeuKfRncG2+2nvxiigS04TcZIi
         8YQnvkd4j9z5VHNiChgPtQZMW4422XNr48R2/we0jQ4TNqiSPo2nwyAKwTJBao7Crsg/
         cx1p9Bv0oCGq5lGFpvDvDs91udXIiuhQfkLaimLw5zKlthyniQhGjtumJsfNBpU3QpdC
         5nSQ==
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=UOzg80zYuLiWvWHgei1XU2niJmTNjVNaIbA4v/aF0rg=;
        b=jPNJPCR0Bm34noF8miWEDnqXezfVgX/fudn6eLvrzBtxhuKIDC7Zc80nblmbhFYxNz
         5i3m6zmw8qxIbviH9PKhZpZZylTthFSTX9OIwHHuwPFkE0kpcRhpGzNdhpZ9mND9RtUX
         3YeJZ/BiQRcWyun0Oikaxm5AYDKm5NOpkBuPZXjilHsR85vxyabdC1k6CDLutujvfdy6
         SHSS/JQ7YDhO5LfwWuy9UR2tO/GzljKw5FUKd+xcRpZ8MaRlZrDsLeAuhhm8ggaiVwOK
         eCWVo5t4cOYye5nCAZxi8VU226iVyCCPUT0iHRpzybfyjOWj0eMqenGuSV6CxVSfZ8ql
         g99g==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com;
       spf=pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:4003:c06::235 as permitted sender) smtp.mailfrom=ville.voutilainen@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:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=UOzg80zYuLiWvWHgei1XU2niJmTNjVNaIbA4v/aF0rg=;
        b=HtVWcSQ6RIaBHP33qxon+eG5/IK7CJT5S8fxOCRhY7pONJJbPOkJN3HXoHZi1S1C/N
         Px2AztA76tSiv4bWwub4FgK5PUDkD99HvacTIvu7YRpaRTrObJbWIhACAOPHdhFkJl6j
         y/u98UHQwSKQhiB0+ObSgCAgW4Tds9PoCkkLSTxyg1XRhPay+wJTOKEbYXYPWszXoXTw
         GG3GOihZtA4FiRFjFIOw+kLKQ1LHv+YS8PUJ/Hq0yjYzBDYdASSc3vGNJUUj7NXQm2A1
         aAQRAy2PKrDPnqSVYp4zvVbi9ameDacrKerN8rp7E8FIrMIY5vC6o23/nvII9jhG4khI
         JyFQ==
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=UOzg80zYuLiWvWHgei1XU2niJmTNjVNaIbA4v/aF0rg=;
        b=lW0mGhRs2N+7qjXl/jYVM8k7Ms3B11xBujXl1GmZwoUwpYej6GbXj/HSc4+vviJBGh
         hsptkk+BFDTwQtH/DYts1X+QHp3OOQMIxYiAfTReTo32Parg94N+S4KU5Y6jZxSMbaEc
         cqW85X+aYqIdfomR4x952fUXmzFdc1RxBU+HAE2l6QZ7METNEs77g9yo0+bIQcyKIKTh
         j9LtFQTH0UfiALDCICVwId5k8Gt6f7PjQZ8N0PV4gT8yk6GCZ60XLNI06NlR9qhsBcbs
         ljB3WRQyzuDoz5fXysXrz60A48FjNqT3TDG+RMRtjql1GLWXVZ7KGZ30lyBrGvg+fmZM
         njsQ==
X-Gm-Message-State: AODbwcBK6AuY8fXPVAbT0K0KjvtxQ43dF+lwWeFQcxW9TxgE9w3uACA8
	gdifGyLmgWrJJw==
X-Received: by 10.36.92.66 with SMTP id q63mr4469652itb.35.1494945431483;
        Tue, 16 May 2017 07:37:11 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.36.69 with SMTP id p63ls1542495ota.9.gmail; Tue, 16 May
 2017 07:37:10 -0700 (PDT)
X-Received: by 10.202.228.141 with SMTP id b135mr2156278oih.56.1494945430697;
        Tue, 16 May 2017 07:37:10 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1494945430; cv=none;
        d=google.com; s=arc-20160816;
        b=et9o7P+BVl9Iryhp2d5zcz5uKOpsVRcnlaDcAKvOSSIcGl7bx3pI00CZlIaPBpmzW/
         eYoXcde53Rc4EFUCDpHn8GqNgEsS8jod9Cmxl/tPV/LeyzRfjDTEeD3tMtBaN5Xj4dVX
         gXP6w0XiC65TPWtZ76zN5WT4fip/b8ozH27NPVSC6eBXba28ijbj5HSxiQeffwr9nohw
         kWwWiZ3uNTlJPkEUKOU9BLjVyDOVEU7AtXC53EwUvFxOWC14ixVfPTFQnbGX/WQX6n2J
         O/kLOQJUHkP9VIrY3icH30Ivzvt02+JdcWL4HhC/fitu6AmtELpAZhoI4zDk6qv1Gafp
         SUoQ==
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=PP3C5FAyilYvTOZAphxmPN7rBDeFg8E1VD/mWkqRqAw=;
        b=buujnltmjW5MflHwLGhre9WXGUfc3RuT9kYJQWojGU7p7/vKQFqDI+hHT4QS1nyE/t
         Y//RvaF5zpKv7ezCN7cnZZsHBVSNucFTzBz7i+/cxr8iwkkDhxHuR1yj1wKuS/3IHRJC
         Q+xa06qwoeRu6pEc0FyiATMPJmsb69ohl+YqbjeSScIaB/hFbs6uX75BD6TilAI7ODdh
         4IlCVVrJ4zM4lJiacWh0lZgucbqVUZCwXLd6SiwqQy8HZrr7tIt8pHV/Eg4Co8hiFhLT
         /X4lskzztKjNQYrlwlq8gj+8zE/iaa66AoLUXnbTt6aTE9AlZ1vUCrxj3SRrshdufawq
         OoJQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com;
       spf=pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:4003:c06::235 as permitted sender) smtp.mailfrom=ville.voutilainen@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-oi0-x235.google.com (mail-oi0-x235.google.com. [2607:f8b0:4003:c06::235])
        by mx.google.com with ESMTPS id v3si942335oib.199.2017.05.16.07.37.10
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 16 May 2017 07:37:10 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:4003:c06::235 as permitted sender) client-ip=2607:f8b0:4003:c06::235;
Original-Received: by mail-oi0-x235.google.com with SMTP id b204so27663155oii.1
        for <std-proposals@isocpp.org>; Tue, 16 May 2017 07:37:10 -0700 (PDT)
X-Received: by 10.157.56.140 with SMTP id p12mr5733813otc.206.1494945430121;
 Tue, 16 May 2017 07:37:10 -0700 (PDT)
Original-Received: by 10.157.17.253 with HTTP; Tue, 16 May 2017 07:37:09 -0700 (PDT)
In-Reply-To: <08ff73f1-6989-393e-ee4e-8158af2e7bed@honermann.net>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 ville.voutilainen@gmail.com designates 2607:f8b0:4003:c06::235 as permitted
 sender) smtp.mailfrom=ville.voutilainen@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:32486
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32486>

On 16 May 2017 at 17:29, Tom Honermann <tom@honermann.net> wrote:
>> On that note, I can cobble together something like
>>
>>       std::pair<Key, const char *> parseKey(const char *);
>>       std::pair<Value, const char *> parseValue(const char *);
>>
>>       std::pair<KVPair, const char *> parseKVPair(const char *in)
>>       {
>>           if (*in++ != '(') throw Failure();
>>           auto [Key k, =in] = parseKey(in);
>>           if (*in++ != ',') throw Failure();
>>           auto [Value v, =in] = parseValue(in);
>>           if (*in++ != ')') throw Failure();
>>           return {KVPair(k, v), in};
>>       }
>>
>> So two things there, allow specifying the type of a binding (my
>> favorite thing that structured bindings
>> don't let me do) and allow the binding to assign instead of initializing.
>>
> I like this, but still prefer the following syntax discussed in Issaquah to
> specify a type constraint rather than something that looks like a variable
> declaration with non-obvious conversion semantics:
>
>      std::pair<Key, const char *> parseKey(const char *);
>      std::pair<Value, const char *> parseValue(const char *);
>
>      std::pair<KVPair, const char *> parseKVPair(const char *in)
>      {
>          if (*in++ != '(') throw Failure();
>          auto [k -> Key, =in] = parseKey(in);
>          if (*in++ != ',') throw Failure();
>          auto [v -> Value, =in] = parseValue(in);
>          if (*in++ != ')') throw Failure();
>          return {KVPair(k, v), in};
>      }


Well, with the idea I cobbled together, I can write

auto [x, =k->Key] = parseKey();

and it means something completely different, because -> is a member
access operator. So we can safely
assume that k is an entity that supports operator->, and my binding
there assigns to k->Key. It's such fun
to try to extend a language where all good syntaxes have been taken a
long time ago. :)

-- 
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/CAFk2RUaBhq7KVukgRMvqBMuBiBwZmCf%2BxZpD9jRtBberFoU2Rg%40mail.gmail.com.

.
