220 40247 <b917d650-33b0-459d-bba0-c0f03bc4db8d@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Jack Adrian Zappa <adrian.hawryluk@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::between ?
Date: Fri, 28 Sep 2018 07:26:13 -0700 (PDT)
Lines: 188
Approved: news@gmane.org
Message-ID: <b917d650-33b0-459d-bba0-c0f03bc4db8d@isocpp.org>
References: <7b85d688-9013-407d-b7d3-10d28494e960@isocpp.org>
 <CAFdMc-36tAQ1JJxYOz3PEKv1qnGs=WPGN3NWWKCEwY+SgNdDXA@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_366_1791222983.1538144773718"
X-Trace: blaine.gmane.org 1538144655 24194 195.159.176.226 (28 Sep 2018 14:24:15 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 28 Sep 2018 14:24:15 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCULLOGNUQIRBBXUXDOQKGQES2UA2AA@isocpp.org Fri Sep 28 16:24:10 2018
Return-path: <std-proposals+bncBCULLOGNUQIRBBXUXDOQKGQES2UA2AA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw1-f71.google.com ([209.85.161.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCULLOGNUQIRBBXUXDOQKGQES2UA2AA@isocpp.org>)
	id 1g5tgb-00063z-KU
	for gclcip-std-proposals@m.gmane.org; Fri, 28 Sep 2018 16:24:06 +0200
Original-Received: by mail-yw1-f71.google.com with SMTP id p127-v6sf3618807ywg.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 28 Sep 2018 07:26:16 -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=+AuF9iBOrsdH6MkaQ2PHTZ3dr2EefkzXd5WYPjxpp9M=;
        b=cRDX/cNKs38ku6vjhuDAHO3SZcBJIu2QJEw/Hqi/6rR7DuWkA93AScImahNt7ZrT64
         o4dVxmGUOTgzgcmk+6g7wDD94wp/0CPDFk8sy5R0jsCCJ1ANGi+LXze/tIIYMjrGJIAv
         XPKYBfZWbLaUB6lR/uVFQC/yBAtqCt6CB7w2POl8iot9AYJLHO5VSWLrmSA+9gEkIruu
         Ka7pQ1JpnwR+UnsIB5IbiJFwqlCwT41lHqWSfS4ZGMWWU77mEXaaWvsJn/6fAbN15pi8
         /D6KQ1m86zNwqgxs5woUlkTiqkDWpqxbkp4zQNK9u37V6E18zWqEYQSeAK7KLaEvxDFu
         nbJw==
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=+AuF9iBOrsdH6MkaQ2PHTZ3dr2EefkzXd5WYPjxpp9M=;
        b=u4/L/JsnqpD5Yyjt+5lmUC/rl9Q2CEGrOyBw3PS6aiQcoIyibrh00m/eF4bKC2ez5E
         1T+H8MrtH0Ph/n9Rd5NqrUSQENzp8HFpklrv9uX0PZ9vqEb5JIzrRApf3jFfyXumQULD
         heOxcM+E/Xm2tnYD6GrzDH5XtBRwty/vQYzWwL3Se22gesazH9QAwrr83mzwGxAdeOam
         QvtZOJJEWKg1Tf0mvqxGcGQLkvL5Uh6xbRmR5Z2ONw2Zwwp7POV5KISITEkzt97lEE9k
         E2KtPE1t23MTRcOf2vcQJ5uORXE7hRMaHqgRCPmcvdoQCyVQPX1Kr22l3cK/TLems74C
         dHNA==
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=+AuF9iBOrsdH6MkaQ2PHTZ3dr2EefkzXd5WYPjxpp9M=;
        b=KRY3w5Il6Le6SkmdYGB4mr/dA2WkaAcGavd6zMsAREyGcixXOo1XBrOAoloFzs5sOm
         e1I8JIzWf9Ao7hQ/rfolKEUmy+Mh3YI3ZeKobdSNuWA7NlcPbwTMw3WnCa3n9a6VOmNb
         /r/Ehp+4P1tA0dd6BrbsxKCvePKXN9+Glgb3M6D+cks/YLMmVxhrHqVl1Prj4UNiSCiC
         jUJKld1W5g1FhrslU52DX4N0ld+zpfZOz68JAJPfjRSdDIRVdTwhVxo7d++jUeTOn3bR
         4CSal+IJuUQ2tj/bWRDfkTrka4R+tsoHaIqiQgh+cRl+A/kI/XFKSXBzhxJli3V8hZl8
         KoVQ==
X-Gm-Message-State: ABuFfojbRTqYiKzC6GcjvmS71Ra6EKjAuQM9FDmz41Ns4MEcUp0gBqri
	mrxxXI87VSxO28B5cPrj8aGAQg==
X-Google-Smtp-Source: ACcGV63UUqFEJlVkoTh7wiXrDyfcq8VdELG7P18VDboHRSDVsGBPz673ELLPiR+SkV0cmLhiJ75Ddg==
X-Received: by 2002:a81:9d8c:: with SMTP id u134-v6mr5293670ywg.19.1538144775998;
        Fri, 28 Sep 2018 07:26:15 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:2f8e:: with SMTP id v136-v6ls141632ywv.7.gmail; Fri, 28
 Sep 2018 07:26:14 -0700 (PDT)
X-Received: by 2002:a81:63d5:: with SMTP id x204-v6mr173195ywb.5.1538144774301;
        Fri, 28 Sep 2018 07:26:14 -0700 (PDT)
In-Reply-To: <CAFdMc-36tAQ1JJxYOz3PEKv1qnGs=WPGN3NWWKCEwY+SgNdDXA@mail.gmail.com>
X-Original-Sender: adrian.hawryluk@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:40247
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40247>

------=_Part_366_1791222983.1538144773718
Content-Type: multipart/alternative; 
	boundary="----=_Part_367_582198880.1538144773718"

------=_Part_367_582198880.1538144773718
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



On Friday, September 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrote:
>
> I stepped into this too many times.
> One of the issues are the four < vs <=3D combinations.
>
> The way I solved is by creating a temporal object that allows chain=20
> comparison, and a cast-to-bool operator.
>
> if (chain(3) < x < 4)=20
>

So, something similar to the solution I provided?  As I said, that solution=
=20
would probably result in possible unnecessary comparisons (no logical short=
=20
circuiting) and additional storage for bool propagation (though I've not=20
looked at what the optimizer would do).  Would prolly be better to=20
implement in the language to avoid those issues, even if it is only=20
syntactic sugar, as it can make the code more readable.
=20

>
>
> El jue., 27 de sep. de 2018 a la(s) 12:53, Addy (acl...@gmail.com=20
> <javascript:>) escribi=C3=B3:
>
>> 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
> Who=E2=80=99s got the sweetest disposition?
> One guess, that=E2=80=99s who?
> Who=E2=80=99d never, ever start an argument?
> Who never shows a bit of temperament?
> Who's never wrong but always right?
> Who'd never dream of starting a fight?
> Who get stuck with all the bad luck?=20
>

--=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/b917d650-33b0-459d-bba0-c0f03bc4db8d%40isocpp.or=
g.

------=_Part_367_582198880.1538144773718
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, September 28, 2018 at 7:03:19 AM UTC-4,=
 Daniel Gutson wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">I stepped into this too many times.<div>One of the issues are the =
four &lt; vs &lt;=3D combinations.</div><div><br></div><div>The way I solve=
d is by creating a temporal object that allows chain comparison, and a cast=
-to-bool operator.</div><div><br></div><div>if (chain(3) &lt; x &lt; 4)=C2=
=A0</div></div></blockquote><div><br></div><div>So, something similar to th=
e solution I provided?=C2=A0 As I said, that solution would probably result=
 in possible unnecessary comparisons (no logical short circuiting) and addi=
tional storage for bool propagation (though I&#39;ve not looked at what the=
 optimizer would do).=C2=A0 Would prolly be better to implement in the lang=
uage to avoid those issues, even if it is only syntactic sugar, as it can m=
ake the code more readable.</div><div>=C2=A0</div><blockquote class=3D"gmai=
l_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;=
padding-left: 1ex;"><div dir=3D"ltr"><div><br></div></div><br><div class=3D=
"gmail_quote"><div dir=3D"ltr">El jue., 27 de sep. de 2018 a la(s) 12:53, A=
ddy (<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Pdi=
dvbTJAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39=
;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">=
acl...@gmail.com</a>) escribi=C3=B3:<br></div><blockquote class=3D"gmail_qu=
ote" 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 `s=
td::between()` that would take two arguments and an optional third (compare=
 function) argument.</div><div><br></div><div>Similar to this:=C2=A0<a href=
=3D"https://gist.github.com/martinmoene/9410391" target=3D"_blank" rel=3D"n=
ofollow" onmousedown=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;" onclick=3D=
"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github=
..com%2Fmartinmoene%2F9410391\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHAHmAn=
QG0jdVckwnN0Ql10D1V5-A&#39;;return true;">https://gist.github.com/<wbr>mart=
inmoene/9410391</a><br></div><div><br></div><div>templated&lt;typename T, t=
ypename Compare&gt;</div><div>bool std::between(T lower, T upper, Compare c=
omp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lower) &amp;&amp; comp=
(upper);</div><div>}</div><div><br></div><div>Does anything like this exist=
? Should I propose it!?</div></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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
PdidvbTJAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"PdidvbTJAAAJ" rel=3D"nofollow" 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" target=3D"_blank" =
rel=3D"nofollow" 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/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/7b85d688-9013-407d-<wbr>b7d3-=
10d28494e960%40isocpp.org</a><wbr>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
>Who=E2=80=99s got the sweetest disposition?<br>One guess, that=E2=80=99s w=
ho?<br>Who=E2=80=99d never, ever start an argument?<br>Who never shows a bi=
t of temperament?<br>Who&#39;s never wrong but always right?<br>Who&#39;d n=
ever dream of starting a fight?<br>Who get stuck with all the bad luck? </d=
iv>
</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/b917d650-33b0-459d-bba0-c0f03bc4db8d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b917d650-33b0-459d-bba0-c0f03bc4db8d=
%40isocpp.org</a>.<br />

------=_Part_367_582198880.1538144773718--

------=_Part_366_1791222983.1538144773718--

.
