220 14506 <70a52592-8f61-4fc2-855e-f65d73af9be8@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Olaf van der Spek <olafvdspek@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Range-based if
Date: Wed, 12 Nov 2014 11:33:29 -0800 (PST)
Lines: 101
Approved: news@gmane.org
Message-ID: <70a52592-8f61-4fc2-855e-f65d73af9be8@isocpp.org>
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: multipart/alternative; 
	boundary="----=_Part_898_1511322349.1415820809109"
X-Trace: ger.gmane.org 1415820818 4348 80.91.229.3 (12 Nov 2014 19:33:38 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 12 Nov 2014 19:33:38 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5NB45SSABBBCPMR2RQKGQELBVVIBA@isocpp.org Wed Nov 12 20:33:32 2014
Return-path: <std-proposals+bncBC5NB45SSABBBCPMR2RQKGQELBVVIBA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ie0-f197.google.com ([209.85.223.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5NB45SSABBBCPMR2RQKGQELBVVIBA@isocpp.org>)
	id 1XodfW-0004AU-Ps
	for gclcip-std-proposals@m.gmane.org; Wed, 12 Nov 2014 20:33:30 +0100
Original-Received: by mail-ie0-f197.google.com with SMTP id rd18sf69704573iec.8
        for <gclcip-std-proposals@m.gmane.org>; Wed, 12 Nov 2014 11:33:30 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=LLfxepIaAnrmlMqAKZjpib/fbdkeFoO5RikmtaUNto0=;
        b=HH5UBkKVxZ9emrJ8dVO9mGc+QHanZ3kkoTxIpHqon95J2X/NZokyGANt9D/tCLxjVi
         YLUfMDa3uZWdk7Fxe5sT1KxJ/UBsTUjeN9mzuTqfD3/69OIjqwTp3lVxQ6B77sKP6GYA
         C7l8IRrFz0hsXaKktLBglmS2bWSFX5YyWNbDb961mJQuUc6SwzcnohIxPvgIa9mR45KQ
         6xeW+kMpt6IGeCtjpG71snEv+hoU7ooCBe/Ajv+6oB2cy3RhzNloCPIyzCRWTPHJjCSY
         rMXCOWaMA/Ikqz8Izd4FJ0uOW8A0d7duEe1Y3Owcbowh3QC9GiRtlb1wv79eWumrnSH1
         AOew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=LLfxepIaAnrmlMqAKZjpib/fbdkeFoO5RikmtaUNto0=;
        b=cp2+3d86vvAh0QfWEIO0K08fNPBKtsNMK1yJj0IMLcd62cqxb3Dr16t6DoutVQokMm
         EFEiB6eAjWzTD5zmTutcm277UZs8+K4nSjNteTPsHhLTvmSmt8uxiHeqM8g+kRNbDpyX
         43gCQVlecBbJe7LXJnMVg0GvAR81bLVOubEDh5E0FkBNSP9sMIJXl7vXdJQ/9eUfFMTU
         KU9TXmftsUSD2uLnURjTjTb3TR5lbPp6El8CRiBL/Smvx2FG3X/2cbtXOEBqeWSExXAN
         RYHLHoV3k/af9SBWBaUmT7+rwuA6+ZeVpcaWeAf5ggHNpoKv9vHMSKPNJlAMGRWjOXP6
         FT4Q==
X-Gm-Message-State: ALoCoQkCkRIuhhP9xi27YCnAXHHGy4ixrmB6WX/TH5XywzuXm9GgCpqzcTfDr4MqA8uNzxsSsno7
X-Received: by 10.182.89.136 with SMTP id bo8mr735850obb.7.1415820810179;
        Wed, 12 Nov 2014 11:33:30 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.85.101 with SMTP id m92ls3079758qgd.51.gmail; Wed, 12 Nov
 2014 11:33:29 -0800 (PST)
X-Received: by 10.140.20.108 with SMTP id 99mr59581qgi.15.1415820809463;
        Wed, 12 Nov 2014 11:33:29 -0800 (PST)
In-Reply-To: <CADbh+eScmZMj4dcQv73re1dM0VNbw_PeHRc_FPWNONoKNKsiMg@mail.gmail.com>
X-Original-Sender: olafvdspek@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: <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:14506
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/14506>

------=_Part_898_1511322349.1415820809109
Content-Type: text/plain; charset=UTF-8

On Wednesday, November 12, 2014 3:39:34 AM UTC+1, Brent Friedman wrote:
>
> > auto first_or_null(auto range) -> decltype(&range.begin())
>
> This assumes pointers, which while addressing some use cases it isn't 
> sufficient for the general case.
>
> >    if (!range.empty())
> >        DoSomething(*range.begin());
>
> This is more or less what we're doing currently. If you need to do more 
> than one something, then it becomes
>
> if (!range.empty())
> {
>     auto&& front = *range.begin();
>     DoSomething( front );
>     //etc
> }
>
> 'range' may of course be an rvalue, perhaps the result of a function call. 
> We do this a lot. Currently, we'll have to create a variable to store 
> 'range'. So introducing an additional scope would be wise to contain 
> 'range'.
>
> {
>   auto& range = GetTheRange();
>   if (!range.empty())
>   {
>       auto& front = *range.begin();
>       DoSomething( front );
>       //etc
>   }
> }
>
>
IMO it'd be nice if this was possible:
if (auto& range = GetTheRange())

-- 

--- 
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/.

------=_Part_898_1511322349.1415820809109
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, November 12, 2014 3:39:34 AM UTC+1, Brent Fr=
iedman wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
&gt;<span style=3D"font-family:arial,sans-serif;font-size:13px">&nbsp;auto =
first_or_null(auto range) -&gt; decltype(&amp;range.begin())</span><div><br=
></div><div>This assumes pointers, which while addressing some use cases it=
 isn't sufficient for the general case.</div><div><br></div><div>&gt;<span =
style=3D"font-family:arial,sans-serif;font-size:13px">&nbsp; &nbsp; if (!ra=
nge.empty())</span></div><span style=3D"font-family:arial,sans-serif;font-s=
ize:13px">&gt; &nbsp; &nbsp; &nbsp; &nbsp;DoSomething(*range.begin());</spa=
n><div><br></div><div>This is more or less what we're doing currently. If y=
ou need to do more than one something, then it becomes</div><div><br></div>=
<div>if (!range.empty())</div><div>{</div><div>&nbsp; &nbsp; auto&amp;&amp;=
 front =3D *range.begin();</div><div>&nbsp; &nbsp; DoSomething( front );</d=
iv><div>&nbsp; &nbsp; //etc</div><div>}</div><div><br></div><div>'range' ma=
y of course be an rvalue, perhaps the result of a function call. We do this=
 a lot. Currently, we'll have to create a variable to store 'range'. So int=
roducing an additional scope would be wise to contain 'range'.</div><div><b=
r></div><div>{</div><div>&nbsp; auto&amp; range =3D GetTheRange();</div><di=
v>&nbsp; if (!range.empty())</div><div>&nbsp; {</div><div>&nbsp; &nbsp; &nb=
sp; auto&amp; front =3D *range.begin();</div><div>&nbsp; &nbsp; &nbsp; DoSo=
mething( front );</div><div>&nbsp; &nbsp; &nbsp; //etc</div><div>&nbsp; }</=
div><div>}</div><div><br></div></div></blockquote><div><br></div><div>IMO i=
t'd be nice if this was possible:</div><div>if (auto&amp; range =3D GetTheR=
ange())<br></div><div><br></div><blockquote class=3D"gmail_quote" style=3D"=
margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;=
">
</blockquote></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_898_1511322349.1415820809109--

.
