220 40257 <add8451d-f375-49f3-a5cb-11dd6eb6f53f@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "Ivan G." <nekotekina@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::between ?
Date: Fri, 28 Sep 2018 08:20:53 -0700 (PDT)
Lines: 208
Approved: news@gmane.org
Message-ID: <add8451d-f375-49f3-a5cb-11dd6eb6f53f@isocpp.org>
References: <7b85d688-9013-407d-b7d3-10d28494e960@isocpp.org>
 <CAC+0CCOxq7j=q1SYGHQs-LYiWq6ojoQubBD=ux5vehrMqm7vqQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_390_487983814.1538148053301"
X-Trace: blaine.gmane.org 1538147929 12901 195.159.176.226 (28 Sep 2018 15:18:49 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 28 Sep 2018 15:18:49 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD26JFH7QQHRBVUNXHOQKGQERXHQN7Y@isocpp.org Fri Sep 28 17:18:45 2018
Return-path: <std-proposals+bncBD26JFH7QQHRBVUNXHOQKGQERXHQN7Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb1-f198.google.com ([209.85.219.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD26JFH7QQHRBVUNXHOQKGQERXHQN7Y@isocpp.org>)
	id 1g5uXU-0003Fg-N2
	for gclcip-std-proposals@m.gmane.org; Fri, 28 Sep 2018 17:18:45 +0200
Original-Received: by mail-yb1-f198.google.com with SMTP id 189-v6sf3413557ybz.11
        for <gclcip-std-proposals@m.gmane.org>; Fri, 28 Sep 2018 08:20:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        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;
        bh=eX8NBgnBED2+Ym4fizZ+Jl4G2DpYKJxotqxmwcihA/I=;
        b=XP85D474S250slkvWBGUBJ1+n6mD2y4KI6lPdhLXbb+cOTJjKSeKjqGEIcVtV4H5B2
         OQqoZAK8My8nCFbyfRXdLxmXoYNyFq3huH+X3fWaoRez/Ng7DmMUdP5tONfYl+AitEnQ
         qvLPQh2M1T8QJoSo/pGDdLsfA7nckYGYYO1liK2hVJBlMW+Nqr3q7F6gPDbIt8+jS/hZ
         nHd/P2u/KjWU7eoxpZVbu4h+Sopzjd00keo6yppLAFoZMaofJbqwsMSPLDIarSTJc3vB
         QbGZHxv/xb4281CIP8Gu2/a8O9b+J/jIKQlrHabS69MWtJI5sppSM47rAFtGp6kTSg/f
         SegQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        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;
        bh=eX8NBgnBED2+Ym4fizZ+Jl4G2DpYKJxotqxmwcihA/I=;
        b=Si7e+2AePhvENWoaLvXraGGHUI89lh4Wd5oIaQcPEEWAwf8Vbf88orPjsqIR2adcmh
         AOH66+4YH9jWifCwM0rWR5bi3nBbqpDxipEQ8cOd35hj4xILl0C5WdRC5ULKhIBNAhiX
         1stW71r3C3JKkj0n8RT9xlDj2smN4TUhMyWL+6a6kdNc8H7APDapMtQ5l2huvDWjUB9L
         mgrIt51151nctlKAUaMXumzZ+OB04BVCaPtIKlk5N/YmpFQP+DkmbCH2HnsI2a0+s/1y
         s2I7uiJ/vn8Cu++3V2yLXLv4WSc+OGfjj+o93WP2d1lnXQHRIgS+xrBvtZUrPCbHoct3
         VPfQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        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:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=eX8NBgnBED2+Ym4fizZ+Jl4G2DpYKJxotqxmwcihA/I=;
        b=DkBy2Buf7M4BhbBJ5/+BXT6ygS2mFbKTgvUr/77HN41VJF2eYFvholvOFucbWDlQzf
         KLWbasYsgLSwVC5DfeQST5c836UyZ48RwsPutRNA0k8vfNbs1kOovl2hi53NceVjHCWs
         m69uV5LJXULNQhbZREk09kvPbqFqL9YGL4b4YZqfP9Ox97a2yJ2mphFSdRxQ60a+L6qj
         DYx6TA287rzN4UWZDdIoXbyEFmpyzF30S5cKkQUuGeA4E/Edc+bVu1hNtBPDqto6vaqL
         ap6XV8/Xn+3vHUBj7zlUdMDwMukPtCsjvnlaoIh9DzeqZP0CN0zS9AYLnow1fDPylq3W
         h1Dg==
X-Gm-Message-State: ABuFfoi0VqXljiVw6I43WTP2w9OwPHA8NTIsw5XFIHatbQdqCKzOCyGw
	LRZB14aHG6pVsvd5vouD+aObYA==
X-Google-Smtp-Source: ACcGV61H0g9RaCYQDdyU8E0unv0vIx9Y5QEgIBXcKSLrnUly2Yf0ucwMz9KTadfrF5phszmaqnbDIA==
X-Received: by 2002:a25:af84:: with SMTP id g4-v6mr4849744ybh.99.1538148054933;
        Fri, 28 Sep 2018 08:20:54 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:11d3:: with SMTP id 202-v6ls2730336ywr.9.gmail; Fri, 28
 Sep 2018 08:20:54 -0700 (PDT)
X-Received: by 2002:a81:7bd7:: with SMTP id w206-v6mr170369ywc.3.1538148053908;
        Fri, 28 Sep 2018 08:20:53 -0700 (PDT)
In-Reply-To: <CAC+0CCOxq7j=q1SYGHQs-LYiWq6ojoQubBD=ux5vehrMqm7vqQ@mail.gmail.com>
X-Original-Sender: nekotekina@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:40257
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40257>

------=_Part_390_487983814.1538148053301
Content-Type: multipart/alternative; 
	boundary="----=_Part_391_1147302689.1538148053301"

------=_Part_391_1147302689.1538148053301
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I'd like to see some kind of a range operator, for example, 100..200=20
returns special integral range type.
Then use some another operator to check whether a number is within this=20
range, for example:
    if (x & -100..100)
   {
   }







=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D1=81=D0=B5=D0=BD=D1=82=D1=
=8F=D0=B1=D1=80=D1=8F 2018 =D0=B3., 19:07:24 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Jake Arkinstall=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> It has come up before. The issue is that a<b<c is evaluated as (a<b)<c,=
=20
> where (a<b) is a bool. We would thus need a special case to deal with thi=
s.
>
> Personally, I don't imagine that people are actually using a<b<c to=20
> compare the comparison (a<b) against c. Its possible, though, and so addi=
ng=20
> a special case for comparisons will break something somewhere. I want it,=
=20
> it's lovely syntax, but backwards compatibility is lovely too, even in=20
> cases where legacy code is doing something bizarre.
>
> On Thu, 27 Sep 2018, 16:53 Addy, <acl...@gmail.com <javascript:>> wrote:
>
>> I do this pattern often:
>>
>> if (0 < x && x < 100)
>>
>> And would love a simple `std::between()` that would take two arguments=
=20
>> and an optional third (compare function) argument.
>>
>> Similar to this: https://gist.github.com/martinmoene/9410391
>>
>> templated<typename T, typename Compare>
>> bool std::between(T lower, T upper, Compare comp)
>> {
>>     return comp(lower) && comp(upper);
>> }
>>
>> Does anything like this exist? Should I propose it!?
>> --=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-90=
13-407d-b7d3-10d28494e960%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-9=
013-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>

--=20
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 e=
mail 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/add8451d-f375-49f3-a5cb-11dd6eb6f53f%40isocpp.or=
g.

------=_Part_391_1147302689.1538148053301
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I&#39;d like to see some kind of a range operator, fo=
r example, 100..200 returns special integral range type.</div><div>Then use=
 some another operator to check whether a number is within this range, for =
example:</div><div><div style=3D"background-color: #FAFAFA; border-color: #=
BBB; border-style: solid; border-width: 1px; word-wrap: break-word;" class=
=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<div style=3D"color: #000000;background-color: #ffffff;font-family: &#39;Dr=
oid Sans Mono&#39;, &#39;monospace&#39;, monospace, &#39;Droid Sans Fallbac=
k&#39;;font-weight: normal;font-size: 14px;line-height: 19px;white-space: p=
re;"><div><span style=3D"color: #000000;"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">=C2=A0 =C2=A0 </span></span><span style=3D"color: =
#af00db;"><span style=3D"color: #008;" class=3D"styled-by-prettify">if</spa=
n></span><span style=3D"color: #000000;"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">x </span></span><span style=3D"color: #000000;"><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&amp;</span></span><span style=3D"colo=
r: #000000;"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan></span><span style=3D"color: #000000;"><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">-</span></span><span style=3D"color: #09885a;"><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">100</span></span><s=
pan style=3D"color: #000000;"><span style=3D"color: #066;" class=3D"styled-=
by-prettify">.</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">.</span></span><span style=3D"color: #09885a;"><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">100</span></span><span style=3D"color: #0=
00000;"><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><=
/span></div><div><span style=3D"color: #000000;"><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span></span></div><div><span style=
=3D"color: #000000;"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> =C2=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">}</span></span></div></div><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br><br><br></span></div></code></div><br><br></div><div>=
<div><br></div></div><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D1=
=81=D0=B5=D0=BD=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2018 =D0=B3., 19:07:24 UTC+3 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Ja=
ke Arkinstall =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"auto">It has come up before. The is=
sue is that a&lt;b&lt;c is evaluated as (a&lt;b)&lt;c, where (a&lt;b) is a =
bool. We would thus need a special case to deal with this.<div dir=3D"auto"=
><br></div><div dir=3D"auto">Personally, I don&#39;t imagine that people ar=
e actually using a&lt;b&lt;c to compare the comparison (a&lt;b) against c. =
Its possible, though, and so adding a special case for comparisons will bre=
ak something somewhere. I want it, it&#39;s lovely syntax, but backwards co=
mpatibility is lovely too, even in cases where legacy code is doing somethi=
ng bizarre.</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On T=
hu, 27 Sep 2018, 16:53 Addy, &lt;<a href=3D"javascript:" target=3D"_blank" =
gdf-obfuscated-mailto=3D"-Po5HcYrGQAJ" rel=3D"nofollow" onmousedown=3D"this=
..href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;jav=
ascript:&#39;;return true;">acl...@gmail.com</a>&gt; wrote:<br></div><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"ltr">I do this pattern often:<div><br>=
</div><div>if (0 &lt; x &amp;&amp; x &lt; 100)</div><div><br></div><div>And=
 would love a simple `std::between()` that would take two arguments and an =
optional third (compare function) argument.</div><div><br></div><div>Simila=
r to this:=C2=A0<a href=3D"https://gist.github.com/martinmoene/9410391" rel=
=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;https://www=
..google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fmartinmoene%2F9410391\=
x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A&#39;;r=
eturn true;" onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3dht=
tps%3A%2F%2Fgist.github.com%2Fmartinmoene%2F9410391\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A&#39;;return true;">https://gi=
st.github.com/martinmoene/9410391</a><br></div><div><br></div><div>template=
d&lt;typename T, typename Compare&gt;</div><div>bool std::between(T lower, =
T upper, Compare comp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lowe=
r) &amp;&amp; comp(upper);</div><div>}</div><div><br></div><div>Does anythi=
ng like this exist? Should I propose it!?</div></div>



-- <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"javascript:" rel=3D"nofollow" target=3D"_blank" gdf-obfu=
scated-mailto=3D"-Po5HcYrGQAJ" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" rel=3D"nofollo=
w" target=3D"_blank" gdf-obfuscated-mailto=3D"-Po5HcYrGQAJ" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7b85d688-9013-407d-b7d3-10d28494e960%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/7b85d688-9013-407d-b7d3-10d28494e960%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/7b85d688-9013-407d-b7d3-10d28494e960%40=
isocpp.org</a>.<br>
</blockquote></div>
</blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/add8451d-f375-49f3-a5cb-11dd6eb6f53f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/add8451d-f375-49f3-a5cb-11dd6eb6f53f=
%40isocpp.org</a>.<br />

------=_Part_391_1147302689.1538148053301--

------=_Part_390_487983814.1538148053301--

.
