220 27704 <57A8E703.5070402@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Matthew Woehlke <mwoehlke.floss@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Extend the range-based for statement
Date: Mon, 8 Aug 2016 16:09:39 -0400
Lines: 28
Approved: news@gmane.org
Message-ID: <57A8E703.5070402@gmail.com>
References: <152c8499-aa2f-4e23-aeec-cd055f06a6da@isocpp.org>
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 1470686987 26904 195.159.176.226 (8 Aug 2016 20:09:47 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 8 Aug 2016 20:09:47 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.1.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC37LBFWUIFBBBWOUO6QKGQEXASZ3GY@isocpp.org Mon Aug 08 22:09:43 2016
Return-path: <std-proposals+bncBC37LBFWUIFBBBWOUO6QKGQEXASZ3GY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f200.google.com ([209.85.217.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC37LBFWUIFBBBWOUO6QKGQEXASZ3GY@isocpp.org>)
	id 1bWqrm-0006qn-Rd
	for gclcip-std-proposals@m.gmane.org; Mon, 08 Aug 2016 22:09:42 +0200
Original-Received: by mail-ua0-f200.google.com with SMTP id u13sf85641987uau.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 08 Aug 2016 13:09:43 -0700 (PDT)
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=RL3I7BWKERNuv4ckKX2qadM1QkYbl5G2tf9NhwYMsNA=;
        b=wyquZEpRdJsB8PcNcj7C3AKpTgsTzSJP0RJ565hGRxrJJNQS58wSiZ83zoRVCsHefH
         pDIdZGtJ59FtxbivBiwQ79yU4GZURytv/8XBuovrAgIz9MJTWegP4xshl90byDrI7sf3
         jY3e5/CSLEOvNlTj/0uor8N/3Yr3zNlsvKDE+rP+COND8yNet2fMf301aJ3ilEKTbWKu
         rTXW3ulnFhRQNRFnz0Gyvn2iLjE0SCkK6QLDyUZMFYExd14h5Edf+lgGkRB3pLeIdprS
         mIEjQFUY7gEnk+CKO3d1/RowTg/BUGNSxdArohbh0XjoRSt1KvpRkAXUuZIUvRc/yuwZ
         rBEw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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=RL3I7BWKERNuv4ckKX2qadM1QkYbl5G2tf9NhwYMsNA=;
        b=HBguUDEPdIyzYo59UkBDO+Z7MBE+LxB3MtKQ1AMHhWeQ0YF4I92pSH0ebfXhaQYb3j
         N046/lbGbruN75yJeDjE3qCtzq9T/GeIgCkYc6S/Kqbux1OWE3orSIok2t6WjRBKRohk
         L/PkgID2+/S+4LSiZYp+zJWRAYY8HJOZg59Q9P2IAP4+RY8hKMuPX2Osnlh+u+Lnxppk
         UWnr87MMgTdP12WbgWzBTVNUafJuwCDJs8LHDC0DeZbwDOuoQ73yy/yiVZ9mf7MCyOoO
         mWmKR1vXgU2DiypqP1jv4nrIYs+rGui4+h5aY1j38Ujfn1D7iJjERWFrdMWi3DQoEVAE
         7btg==
X-Gm-Message-State: AEkoouv0Z4qlUvEejPfLI4854vAbYNJaHD+p9pRvDZgdzduoPzSidrv11tlIKEkMYNDUDw==
X-Received: by 10.237.44.38 with SMTP id f35mr81328119qtd.18.1470686982907;
        Mon, 08 Aug 2016 13:09:42 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.36.81 with SMTP id p75ls1292885ota.18.gmail; Mon, 08 Aug
 2016 13:09:42 -0700 (PDT)
X-Received: by 10.200.52.193 with SMTP id x1mr29379886qtb.65.1470686982157;
        Mon, 08 Aug 2016 13:09:42 -0700 (PDT)
Original-Received: from mail-qk0-x22b.google.com (mail-qk0-x22b.google.com. [2607:f8b0:400d:c09::22b])
        by mx.google.com with ESMTPS id c86si18498649qkh.62.2016.08.08.13.09.42
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 08 Aug 2016 13:09:42 -0700 (PDT)
Received-SPF: pass (google.com: domain of mwoehlke.floss@gmail.com designates 2607:f8b0:400d:c09::22b as permitted sender) client-ip=2607:f8b0:400d:c09::22b;
Original-Received: by mail-qk0-x22b.google.com with SMTP id x185so140626930qkc.2
        for <std-proposals@isocpp.org>; Mon, 08 Aug 2016 13:09:42 -0700 (PDT)
X-Received: by 10.55.122.4 with SMTP id v4mr11906122qkc.136.1470686981726;
        Mon, 08 Aug 2016 13:09:41 -0700 (PDT)
Original-Received: from [192.168.1.173] (tripoint.kitware.com. [66.194.253.20])
        by smtp.googlemail.com with ESMTPSA id j188sm15460070qke.22.2016.08.08.13.09.40
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 08 Aug 2016 13:09:41 -0700 (PDT)
X-Enigmail-Draft-Status: N1110
In-Reply-To: <152c8499-aa2f-4e23-aeec-cd055f06a6da@isocpp.org>
X-Original-Sender: mwoehlke.floss@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 mwoehlke.floss@gmail.com designates 2607:f8b0:400d:c09::22b as permitted
 sender) smtp.mailfrom=mwoehlke.floss@gmail.com;       dmarc=pass (p=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:27704
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27704>

On 2016-08-07 16:49, Antonio Perez wrote:
> I propose that the range-based for statement is expanded to allow iteration 
> through multiple for-range-initializes simultaneously [...]

Some general observations along the lines of the other replies...

A std::zip needn't be too expensive. It doesn't need to fully construct
a return object, and in fact probably *shouldn't*. At worst you have a
little bit of local state.

Another reason to go with something like std::zip is that you can
combine it with other iterator adaptors to iterate over the longest list
with 'filler' elements when the shorter runs out. Example:

  for(auto&& [x, y] : std::zip(long_list, std::pad(short_list, 0)))

(...where std::pad is a hypothetical function that returns elements of
the input list until it runs out, then returns the filler element forever.)

-- 
Matthew

-- 
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/57A8E703.5070402%40gmail.com.

.
