220 40232 <CAC+0CCOxq7j=q1SYGHQs-LYiWq6ojoQubBD=ux5vehrMqm7vqQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Jake Arkinstall <jake.arkinstall@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::between ?
Date: Thu, 27 Sep 2018 17:07:10 +0100
Lines: 112
Approved: news@gmane.org
Message-ID: <CAC+0CCOxq7j=q1SYGHQs-LYiWq6ojoQubBD=ux5vehrMqm7vqQ@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="000000000000b4e0170576dc8884"
X-Trace: blaine.gmane.org 1538064317 21677 195.159.176.226 (27 Sep 2018 16:05:17 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 27 Sep 2018 16:05:17 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDCZX3WUUQFRBOUAWTOQKGQEKL3FQRA@isocpp.org Thu Sep 27 18:05:13 2018
Return-path: <std-proposals+bncBDCZX3WUUQFRBOUAWTOQKGQEKL3FQRA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it1-f197.google.com ([209.85.166.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDCZX3WUUQFRBOUAWTOQKGQEKL3FQRA@isocpp.org>)
	id 1g5Ymv-0005Yo-B1
	for gclcip-std-proposals@m.gmane.org; Thu, 27 Sep 2018 18:05:13 +0200
Original-Received: by mail-it1-f197.google.com with SMTP id w68-v6sf8356528ith.0
        for <gclcip-std-proposals@m.gmane.org>; Thu, 27 Sep 2018 09:07:24 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1538064443; cv=pass;
        d=google.com; s=arc-20160816;
        b=z0M6RaIsfjG85h0M0XO1DPf05Gjb8hjXMSrqJiGMialWzgjq2fQpvqD/ocrU/T85O7
         P5xYLqAmiT/maZYcpy2dR323qgosReeQcVVVIpG5g6C90B/hCRmfpwc2cOMNzk9b+prc
         t7H2Dl2gBYggKDJC+9ps4YjSS+aG4+4s3BJ8K+c5Je6lpHGVble+QMSngNXKHU04ma0F
         PZPgFTgaK69JJIUPLi0jB1QV0bGXNYGhVKUKX8G5rJTGOwBKDRId6JXkpXKfIs3vQXm+
         uoClFN/zC18LSJsSifYMI39vLvLWco6W05Fk+Pa8yvcpkNmFVmHtLAaIvFQgTFkS3L04
         InBw==
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=Beid8uff84huYYffvZSFGJmbOjjXUmA1AJlDXvfQ/uc=;
        b=NzAXyNLZ/bSRNZlZRzNmaWTdNxakOjvj4FabY1QVcwMbCdoRv9y6I6jL5L93I8HoFi
         S9OBWNuKlq62aU6LTRK7Jd65okrnmMuqMQ5d5brsHTXCd36vnue78tFmOVsCgdjUvCIf
         /Cpm5A5aP5+2OtVivO9L6JCECc3D/NiCf+j1hPmrMV3JN7mzvuNUBcDnxl0c4gQLolNC
         kSYL09JfpSH86ZsfUTlwevZJflh0IFjORy8kJ3v3F6xwCqYF4QpawObuZwHfhExEnESN
         Qntp7iHQybbcX+fkZVK5pQ9pKXWMWFkLdLvoYF3l+/mwhQ3p6me2hQXe7xn6IahFWRN9
         I3Tw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=DkdendeR;
       spf=pass (google.com: domain of jake.arkinstall@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jake.arkinstall@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=Beid8uff84huYYffvZSFGJmbOjjXUmA1AJlDXvfQ/uc=;
        b=Zu6fsuHM1TMACzkZRnMqXm7W7QSSClQzzpMzYqdsWTa6wJOM7IcAxlqXhhwl1b3PvQ
         QQ6UZwI9GOnZZcQeVFT0avgbO8NLkupB/gK90vSmoplb5qajFe4OmTzCasCAkAvUmxJ6
         mbJr1gaBZQ+fC1ouZI+SgcbpXOtrQVWtKzQM3ghW63CkClfkCLmBF/XHBv/M37ZSBaWx
         VL3b95I2uyrTT30OcFjiys6ZXHrFxUaZIRINiIWdIfeSP1Xpb+rSoN3PSsmPW5pBZj4y
         1+L5yCyZjp/hbMciBvh5VELoSSq1hyMNUuWmieomyKT5B8gIoDjLBh/C4sEu1TPNtjsi
         qefw==
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=Beid8uff84huYYffvZSFGJmbOjjXUmA1AJlDXvfQ/uc=;
        b=go4Jv7Sxbi0AmFdfVimh4/Ni92UW6HOCqtiwlWN1vcKCV381QYBLDOtDaA6evDzY/F
         6fH741hLGnZcKcL4lSXg7p/dzqpxOtXxmV61hp9ani4TMeeHCBrHsNky/RS8zFcH5LNJ
         d7QAmV8lHMuKb44XVFa1qlXY8KJL3gNkWdctzqDI4inzRDZnFyukHyysJ2thGikKIJhR
         uOeTF2tEzU7oUysX0/Tv5ArG4ZzQmCmcmHnd6wjp8y2zGGW5i2QX30xh8P9cBae9MOIe
         uDBI43U0mLps75IeKS9tsIIKhXtfBGjoHfMglPvMMDP3N0BQYr/0CEJmYmlIoWbQ2NAv
         aPVA==
X-Gm-Message-State: ABuFfojj5c8N2DwYuhsiqRkrsqEWvwiwNE7VbudYZRz3EGAsMqTrifkY
	wSjBzYDHcN/8OlHr04/8gjeA5g==
X-Google-Smtp-Source: ACcGV62uQ+xrZD2jHr6Lk/yz9eLk7GHqgM5H8qu1uoQnUVfJh5bpL2JyFh63KQS8fhFMOQX7YpdT6g==
X-Received: by 2002:a6b:b2c8:: with SMTP id b191-v6mr7534518iof.5.1538064443834;
        Thu, 27 Sep 2018 09:07:23 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a24:4161:: with SMTP id x94-v6ls217232ita.1.gmail; Thu, 27
 Sep 2018 09:07:22 -0700 (PDT)
X-Received: by 2002:a24:7cc6:: with SMTP id a189-v6mr990838itd.42.1538064442519;
        Thu, 27 Sep 2018 09:07:22 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1538064442; cv=none;
        d=google.com; s=arc-20160816;
        b=ZU1tGaNWvgS/+OqODjGViD8uTzL3yxSlznjgCKjBTdHDUJA7NjBL9+NQlEzsU7v6aA
         Hw4gncst4+KSdQe7GN8K1xp/zt8noiAQQWwOUgixsRKsFX6sjlXdTLVoBELP35Pml8qs
         bI8mvbO9KsqsKf61WFid6Ek/SUe9l+I2xhho6JHk1h+uCdLW1jO13QLVldVsrXI34aO5
         merPgNnPUQ1NAy0gPL8CSFEx67IQRrVdiZhgUa1jgbRVkyl+djJrlV4fh13+NKZxKgZU
         9FPl8I9lloyNQDfyhZ006TBWDjYx3hJ8THxVMEazAuMohemY/dOUTMCFZmAOa8t3e8vM
         EPhg==
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=dc9tYnHfYqyLdmQJHpDjgimpy21Y0ztUE3yJ51daG5M=;
        b=CIRN6zoGJHEMALf8zCmXWXKCi0uiSlDSm1Dm2PnduTg6SA0OIFXTBbmU1iXxsgOtNb
         0PmX2Qo+1rfS51RKjxIM+V5NuBePufb5aPTZEoYmyHJy4CQdR++vSSGOfw5D745m4KmG
         wPXbTjA/DYY2aSwLuD4PBUR8l1otoK2oyNfImmnr4qcosdimU6jZbWTjuoQFM8q+n9C0
         VYwlTjuntC+AWzLXOEwy1MyDS+GqGAteY7zO7Kvxnj8XKjT7uYemWSdZNY5RLtZZlfYC
         xCBB/8omeuq9OH0SaIlRuKQ50VZBm3bGdWzeXIlGhCZyPVWbV0ecjlyiWyJem1oGjZmM
         zRdg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=DkdendeR;
       spf=pass (google.com: domain of jake.arkinstall@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jake.arkinstall@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 z15-v6sor783266iol.132.2018.09.27.09.07.22
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Thu, 27 Sep 2018 09:07:22 -0700 (PDT)
Received-SPF: pass (google.com: domain of jake.arkinstall@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a6b:8f44:: with SMTP id r65-v6mr9694790iod.59.1538064441985;
 Thu, 27 Sep 2018 09:07:21 -0700 (PDT)
In-Reply-To: <7b85d688-9013-407d-b7d3-10d28494e960@isocpp.org>
X-Original-Sender: jake.arkinstall@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=DkdendeR;       spf=pass
 (google.com: domain of jake.arkinstall@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=jake.arkinstall@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:40232
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40232>

--000000000000b4e0170576dc8884
Content-Type: text/plain; charset="UTF-8"

It has come up before. The issue is that a<b<c is evaluated as (a<b)<c,
where (a<b) is a bool. We would thus need a special case to deal with this.

Personally, I don't imagine that people are actually using a<b<c to compare
the comparison (a<b) against c. Its possible, though, and so adding a
special case for comparisons will break something somewhere. I want it,
it's lovely syntax, but backwards compatibility is lovely too, even in
cases where legacy code is doing something bizarre.

On Thu, 27 Sep 2018, 16:53 Addy, <aclaure@gmail.com> wrote:

> I do this pattern often:
>
> if (0 < x && x < 100)
>
> And would love a simple `std::between()` that would take two arguments 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!?
>
> --
> 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-9013-407d-b7d3-10d28494e960%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAC%2B0CCOxq7j%3Dq1SYGHQs-LYiWq6ojoQubBD%3Dux5vehrMqm7vqQ%40mail.gmail.com.

--000000000000b4e0170576dc8884
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">It has come up before. The issue is that a&lt;b&lt;c is e=
valuated as (a&lt;b)&lt;c, where (a&lt;b) is a bool. We would thus need a s=
pecial case to deal with this.<div dir=3D"auto"><br></div><div dir=3D"auto"=
>Personally, I don&#39;t imagine that people are 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 break something somewhere. I wa=
nt it, it&#39;s lovely syntax, but backwards compatibility is lovely too, e=
ven in cases where legacy code is doing something bizarre.</div></div><br><=
div class=3D"gmail_quote"><div dir=3D"ltr">On Thu, 27 Sep 2018, 16:53 Addy,=
 &lt;<a href=3D"mailto:aclaure@gmail.com">aclaure@gmail.com</a>&gt; wrote:<=
br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-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 ar=
guments and an optional third (compare function) argument.</div><div><br></=
div><div>Similar to this:=C2=A0<a href=3D"https://gist.github.com/martinmoe=
ne/9410391" target=3D"_blank" rel=3D"noreferrer">https://gist.github.com/ma=
rtinmoene/9410391</a><br></div><div><br></div><div>templated&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(lower) &amp;&amp; co=
mp(upper);</div><div>}</div><div><br></div><div>Does anything like this exi=
st? 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"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank" rel=3D"noreferrer">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" rel=3D"noreferrer">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" =
rel=3D"noreferrer">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.org</a>.<br>
</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/CAC%2B0CCOxq7j%3Dq1SYGHQs-LYiWq6ojoQu=
bBD%3Dux5vehrMqm7vqQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCOx=
q7j%3Dq1SYGHQs-LYiWq6ojoQubBD%3Dux5vehrMqm7vqQ%40mail.gmail.com</a>.<br />

--000000000000b4e0170576dc8884--

.
