220 14495 <1475323.QBNzPAHAPV@tjmaciei-mobl4> article
Path: news.gmane.org!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Range-based if
Date: Wed, 12 Nov 2014 13:13:18 +0900
Lines: 30
Approved: news@gmane.org
Message-ID: <1475323.QBNzPAHAPV@tjmaciei-mobl4>
References: <CADbh+eQCaTPArs7YBUg9mYwrnJ2Gu3SRAfqUbPiLscpyxV8JqQ@mail.gmail.com> <m3tvcu$9ia$1@ger.gmane.org> <CADbh+eScmZMj4dcQv73re1dM0VNbw_PeHRc_FPWNONoKNKsiMg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1415765613 16897 80.91.229.3 (12 Nov 2014 04:13:33 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 12 Nov 2014 04:13:33 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBZF4RORQKGQEMQRXV5A@isocpp.org Wed Nov 12 05:13:26 2014
Return-path: <std-proposals+bncBCB4TK757YBRBZF4RORQKGQEMQRXV5A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wi0-f200.google.com ([209.85.212.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCB4TK757YBRBZF4RORQKGQEMQRXV5A@isocpp.org>)
	id 1XoPJ7-0003Em-Sy
	for gclcip-std-proposals@m.gmane.org; Wed, 12 Nov 2014 05:13:25 +0100
Original-Received: by mail-wi0-f200.google.com with SMTP id h11sf1444344wiw.3
        for <gclcip-std-proposals@m.gmane.org>; Tue, 11 Nov 2014 20:13:25 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:subject:date:message-id:user-agent
         :in-reply-to:references:mime-version:content-type: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=HgCXy/1/Y97QAvFnCjFVIHyQUn75V+QYRvkhBnByGvA=;
        b=ZCisU8giTjgDrvzl6o8nq4oae+zhLWbfKK+jkqK6MXVff1ZBQ1jYUhzZl3S5NkBNPy
         0dfXL35dWCzK1E3VzlAsslRshv0FTzf0B4KfTghCTD+3khzzfWDh+GIRUCCxg1AvMAgo
         YGewqV4eK9otIiQC75DWcdw6m3dc+P37hQpaqtG9yn//ru8NBYd12W5euT7ySaCeNJ2z
         9GAAvyqAJA3I7rvQR0xZCmnop822AT21D70HpL6iahNs+j7I+hfi9VFPAzb7U6kNCTlU
         TGoXrDK34Yqh5F763rrC3Qki1jV4blJJS1BVfYfrBEMyLg5b0865zOLooGmeOenFsHE2
         zFZw==
X-Gm-Message-State: ALoCoQlVvNDY5ZlfCuCbaFJDD8P2Sd7r9P/nfb2n6+qFc4sD90aPBjWcycDSlz6t52QqcWEawndK
X-Received: by 10.180.101.170 with SMTP id fh10mr6090233wib.4.1415765605541;
        Tue, 11 Nov 2014 20:13:25 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.181.11.229 with SMTP id el5ls262592wid.36.canary; Tue, 11 Nov
 2014 20:13:24 -0800 (PST)
X-Received: by 10.180.198.145 with SMTP id jc17mr2315174wic.67.1415765604495;
        Tue, 11 Nov 2014 20:13:24 -0800 (PST)
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [2a01:4f8:d13:f81:21c:14ff:fe01:12a3])
        by mx.google.com with ESMTP id p8si25810722wia.96.2014.11.11.20.13.24
        for <std-proposals@isocpp.org>;
        Tue, 11 Nov 2014 20:13:24 -0800 (PST)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) client-ip=2a01:4f8:d13:f81:21c:14ff:fe01:12a3;
Original-Received: from tjmaciei-mobl4.localnet (jfdmzpr03-ext.jf.intel.com [134.134.139.72])
	by gondolin.macieira.info (Postfix) with ESMTPSA id 7C46F11BD16
	for <std-proposals@isocpp.org>; Tue, 11 Nov 2014 20:13:23 -0800 (PST)
User-Agent: KMail/4.14.2 (Linux/3.16.6-2-desktop; KDE/4.14.2; x86_64; ; )
In-Reply-To: <CADbh+eScmZMj4dcQv73re1dM0VNbw_PeHRc_FPWNONoKNKsiMg@mail.gmail.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3
 as permitted sender) smtp.mail=thiago@macieira.org
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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:14495
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/14495>

On Tuesday 11 November 2014 20:39:32 Brent Friedman wrote:
> Anecdotally, in our codebase of a million or so LOC, this pattern of using
> a looping structure to get the first element in a range constituted about
> 70% of our unreachable code instances.

I must be missing something: what wasn't reachable?

All three non-comment lines in your example would be executed for a non-empty 
range:

for (auto& Item : range)
{
    DoSomething(Item);
    break;
}

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
