220 40237 <CAFdMc-36tAQ1JJxYOz3PEKv1qnGs=WPGN3NWWKCEwY+SgNdDXA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Daniel Gutson <danielgutson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::between ?
Date: Fri, 28 Sep 2018 08:03:05 -0300
Lines: 134
Approved: news@gmane.org
Message-ID: <CAFdMc-36tAQ1JJxYOz3PEKv1qnGs=WPGN3NWWKCEwY+SgNdDXA@mail.gmail.com>
References: <7b85d688-9013-407d-b7d3-10d28494e960@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="000000000000098e670576ec67a0"
X-Trace: blaine.gmane.org 1538132478 32523 195.159.176.226 (28 Sep 2018 11:01:18 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 28 Sep 2018 11:01:18 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDE3NBMV6UFBB5MUXDOQKGQELZDYSVQ@isocpp.org Fri Sep 28 13:01:14 2018
Return-path: <std-proposals+bncBDE3NBMV6UFBB5MUXDOQKGQELZDYSVQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf1-f72.google.com ([209.85.167.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDE3NBMV6UFBB5MUXDOQKGQELZDYSVQ@isocpp.org>)
	id 1g5qWH-0008I8-Jx
	for gclcip-std-proposals@m.gmane.org; Fri, 28 Sep 2018 13:01:13 +0200
Original-Received: by mail-lf1-f72.google.com with SMTP id l17-v6sf1247948lfh.15
        for <gclcip-std-proposals@m.gmane.org>; Fri, 28 Sep 2018 04:03:19 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1538132599; cv=pass;
        d=google.com; s=arc-20160816;
        b=fqz6f9Z74c1oGke2cKl358JODdXPIpGb+HtAwTCOI+IgqjtFidSsCUMeSjOztjKN79
         gpbdvrz8iaxSAB7UpBduQIlsexUtSLLajpac5GJ5SUmg3VSlZ5DJhXeceYXQ7eDr/JH+
         p2juIkkO9NBe5aj9N7GBVdVxCmAnnwbuTA3SHQskPCQLhFT1GyM62JpQEj0pi7asyw2P
         ZSNv9Opcnyt5Yv6z6ydtCYYi0rQqkLKS+grlH5szcaVivcIqHkZWTXgu7VhHfr/k8oYS
         3m2+SDABKHbl4ecE8sCyTPbPnBBD5zT/CBdEWLC14wO9CnqPgyot56FyzVf0qQjfewbz
         w/7A==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:in-reply-to:references:mime-version:dkim-signature;
        bh=NMEE4OMHehbv3x+TGm2+8HMpHHejy7PvFLHh1j3nrts=;
        b=OGd5MVrYIZcSVgB154OQE3KODAweMbgvLcMWV4LsUBsmyhVzmamZYpfxkiC7BabetU
         sDKdHa5fiyULnRlTTxGBHqFO9XY72OjkizL/zGHBFLxvbktP10Vvi3oZx9ORqTE4Wl+0
         YrVgPYf8UwZgA3utXmOO2IZn9tL7HtYVZU6gImV4HaBFkRIKsHEEhr/ssO+dJhcpfAfu
         j2Ahwj8iB7y6urmPwtEmtmwroMqVhWMovw0rbYYktDQEoTTMLPga6nrZvrVrwX3edVtv
         esG07XTlRDsAtB9t5Piwk8AgnQP44axZOn+0tYb+UyWY4FHlJuPXV7EEUBI4Lh0h9i6/
         4nVQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=ev7gzJPX;
       spf=pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=danielgutson@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :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=NMEE4OMHehbv3x+TGm2+8HMpHHejy7PvFLHh1j3nrts=;
        b=qFng87NeQyRF4uJOf0D4tG2XK4pRUcvl4DuZiMMmLol8hd+/uVRZsidZhPmA7dmlQf
         +HLey1Mk5bGVbSF2KjlSn7huS5WgtdRsFQa8iJYt2Dr5FkuwrVhIXS+lDXSjpTqu2sBY
         nyrb54gfwE4Y5/wQl2Pon/10jaa2zzA9goC9uMMRhdn9MqPcbuyLxslqbpzHXq7v/aa2
         txTpeJ5PyNGJ/kwkCYgQMiDQUUXeRMDr8gyahDECYqFYcUC4C8geDMVx88UJZv7TZzHq
         8B9T2eVREBO/E+rL/NpLzcGm/Kc3ZGo7kS/PgSLyf4LVhnSjgZ5TO3nK0q8x3cPo2jVP
         TF3w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject: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=NMEE4OMHehbv3x+TGm2+8HMpHHejy7PvFLHh1j3nrts=;
        b=YjAjhovLsUst1Q/CF5TNEvd+5xW/WCgeIWUc7yaAAmo8tIDqhh2n7nyze51nNlPlwm
         HyGbeR/yGo8ehMBEkZyon+OL9JV5cqmR9KNyZCBRUAxhWd0T3MKXVkZTsot+rNSzsaDa
         6LKZOEAQQIfVMCCoNXfezoBWpXc8xDbe6SZZHkaa7cl0bjCeUxKxYiCih2Zs1Q5jd29c
         nEWXC+kI5Bt/b3jIVL97jdU4+10zSepdnEjKKFMEedDWxPbRraS2MsJ/M0lNPMuRyIKp
         EOFtiAWZPAoP9nUu41USJzq6QjIRbL2SekdKUMhSlh2TUtsNgVE5cbfAeQtbPce+iBXV
         slxA==
X-Gm-Message-State: ABuFfogKuYMOWDXmqLGC5gbXtZlFbuN04yzmYa+jtuKQlf0AmfH3xorC
	qFafTsCb/WK6ODZ/NCWby9092g==
X-Google-Smtp-Source: ACcGV60D2041mLDkkgvilZVrL5gyfCDhoEfDshSh7ibHKwMIiefo+8E/XAQBVm4QVNxJzwGoExq/Mg==
X-Received: by 2002:a19:2013:: with SMTP id g19-v6mr488072lfg.12.1538132599257;
        Fri, 28 Sep 2018 04:03:19 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a19:7007:: with SMTP id h7-v6ls646259lfc.6.gmail; Fri, 28
 Sep 2018 04:03:17 -0700 (PDT)
X-Received: by 2002:a19:be46:: with SMTP id o67-v6mr9739146lff.139.1538132597566;
        Fri, 28 Sep 2018 04:03:17 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1538132597; cv=none;
        d=google.com; s=arc-20160816;
        b=tsuahPsCqf3bQAZGbXdGJNTvaQR5GM+1d8iQ26aNHpUUll7kxWXbSCjwtxzSlmJ75V
         lg6aBN5gVrosDIo6/s7B3zc4WKQhsZm8tJ0VyeaQXkwo+FaezOHB4j+a+/E9YPbFV9qv
         U1PJ2YmYr0aXkKWvNKZqFfkmQxbskDBFhyFpqEDqTnDqwEyiyWYE90YrKo9jVo/QhZVf
         b0RxNzLrJkRMzAa03a15jWJicWPsxae4na3DP13TJhv5BSuX71hS0i9GveJT+2DH9gdA
         KK1tWofny1VqTGabiTeaCgzqHqcsnRLuq7K1taaiXgLtebaZ20CnhDsd70QZif7a+qgL
         EokA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature;
        bh=vo4nDovWSC5T8vnPcZ054rDvUZOwP4IJjc/BlWUYelg=;
        b=y6lsqxWQGErAFUEQVWJwLKyR1V3tJXVCF8tDzQwbmeyv1jfhwBtZcv1+knt2EYAtDt
         MLhmsiQctOSWmHvPYQnUJhsMJam6F7h2RBI97zhsbHs0CeHoQD92EVYXvO+GWqZyBflQ
         agAEm4cGj6i8QHImUBDl7EiaVwg2EeUFVjHXZbP41BYdikPV7j1a+uY7CH5pt6rSpHFN
         XPpxtjLeoTHIdb+pXAoKiVerA4H7CxeiDH6leJwxyr6ifOVm0VO67OwSfIqM5M4A9sDk
         6B5lZZJZz7NM3MESsoVVVxAVluW//vBC/faT7a1YvlieAIodnRoDnSiyjxve9svT17ym
         vyNQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=ev7gzJPX;
       spf=pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=danielgutson@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id e6-v6sor2926860ljg.40.2018.09.28.04.03.17
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Fri, 28 Sep 2018 04:03:17 -0700 (PDT)
Received-SPF: pass (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a2e:4584:: with SMTP id s126-v6mr10917359lja.60.1538132596589;
 Fri, 28 Sep 2018 04:03:16 -0700 (PDT)
In-Reply-To: <7b85d688-9013-407d-b7d3-10d28494e960@isocpp.org>
X-Original-Sender: danielgutson@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=ev7gzJPX;       spf=pass
 (google.com: domain of danielgutson@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=danielgutson@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE 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-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:40237
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40237>

--000000000000098e670576ec67a0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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
comparison, and a cast-to-bool operator.

if (chain(3) < x < 4)



El jue., 27 de sep. de 2018 a la(s) 12:53, Addy (aclaure@gmail.com)
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 an=
d
> 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!?
>
> --
> 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/7b85d688-901=
3-407d-b7d3-10d28494e960%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-90=
13-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>


--=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
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/CAFdMc-36tAQ1JJxYOz3PEKv1qnGs%3DWPGN3NWWKCEwY%2B=
SgNdDXA%40mail.gmail.com.

--000000000000098e670576ec67a0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<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 solved is by creating a temporal object that allows chain comparison, an=
d a cast-to-bool operator.</div><div><br></div><div>if (chain(3) &lt; x &lt=
; 4)=C2=A0<br></div><div><br></div><div><br></div></div><br><div class=3D"g=
mail_quote"><div dir=3D"ltr">El jue., 27 de sep. de 2018 a la(s) 12:53, Add=
y (<a href=3D"mailto:aclaure@gmail.com">aclaure@gmail.com</a>) escribi=C3=
=B3:<br></div><blockquote 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 pat=
tern often:<div><br></div><div>if (0 &lt; x &amp;&amp; x &lt; 100)</div><di=
v><br></div><div>And would love a simple `std::between()` that would take t=
wo 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/mart=
inmoene/9410391" target=3D"_blank">https://gist.github.com/martinmoene/9410=
391</a><br></div><div><br></div><div>templated&lt;typename T, typename Comp=
are&gt;</div><div>bool std::between(T lower, T upper, Compare comp)</div><d=
iv>{</div><div>=C2=A0 =C2=A0 return comp(lower) &amp;&amp; comp(upper);</di=
v><div>}</div><div><br></div><div>Does anything like this exist? Should I p=
ropose 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"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/7b85d688-9013-407d-b7d3-10d28494e960%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-9013-=
407d-b7d3-10d28494e960%40isocpp.org</a>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature" data-smartmail=3D"gmail_signature">Who=E2=80=99s=
 got the sweetest disposition?<br>One guess, that=E2=80=99s who?<br>Who=E2=
=80=99d never, ever start an argument?<br>Who never shows a bit of temperam=
ent?<br>Who&#39;s never wrong but always right?<br>Who&#39;d never dream of=
 starting a fight?<br>Who get stuck with all the bad luck? </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/CAFdMc-36tAQ1JJxYOz3PEKv1qnGs%3DWPGN3=
NWWKCEwY%2BSgNdDXA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-36tAQ1=
JJxYOz3PEKv1qnGs%3DWPGN3NWWKCEwY%2BSgNdDXA%40mail.gmail.com</a>.<br />

--000000000000098e670576ec67a0--

.
