220 40236 <CAP_kE8VspyrrEkbrPNqbhN=JEzAw2BGtgvSWTYQWvEh=2F0CFw@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Adrian H <adrianh.bsc@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::between ?
Date: Thu, 27 Sep 2018 18:07:27 -0400
Lines: 293
Approved: news@gmane.org
Message-ID: <CAP_kE8VspyrrEkbrPNqbhN=JEzAw2BGtgvSWTYQWvEh=2F0CFw@mail.gmail.com>
References: <7b85d688-9013-407d-b7d3-10d28494e960@isocpp.org>
 <CAOHCbitYKvMhz1kkjZCk5Ep1vkFU9ZUwH7kZ+m9_tyG=ueEdcw@mail.gmail.com> <CAOHCbis2t0Dboe3+M23gS9i8zW4+LFWzM9PfTGmkiGUKEQ+BGQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="00000000000033bee00576e19156"
X-Trace: blaine.gmane.org 1538085936 3343 195.159.176.226 (27 Sep 2018 22:05:36 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 27 Sep 2018 22:05:36 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDG2DPUHTAGRBLFJWXOQKGQEAXODQDY@isocpp.org Fri Sep 28 00:05:32 2018
Return-path: <std-proposals+bncBDG2DPUHTAGRBLFJWXOQKGQEAXODQDY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lj1-f198.google.com ([209.85.208.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDG2DPUHTAGRBLFJWXOQKGQEAXODQDY@isocpp.org>)
	id 1g5ePb-0000mi-Gj
	for gclcip-std-proposals@m.gmane.org; Fri, 28 Sep 2018 00:05:31 +0200
Original-Received: by mail-lj1-f198.google.com with SMTP id c16-v6sf1041689lja.20
        for <gclcip-std-proposals@m.gmane.org>; Thu, 27 Sep 2018 15:07:42 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1538086062; cv=pass;
        d=google.com; s=arc-20160816;
        b=DKYqTLyfjaKDs3vDwuXT6ev/wue9qtv77m911ElnW9w3ayt/wDAa8P5AYHkpDVPZj3
         /Pd5+L5gA+BvyFkUbI0owl2wdz32H8PkKLuatEigHVBpwBPTHwlXQy842+/Z4k69srLk
         1pLfFoYAKISpytHLKVYcrLrXJj21Fe11ZB1AfirC64+lPTxjzbZak/VtWc68kOEgUJVz
         DicGx9XA94oU26dE3w/GWVW+Th8cwWuBsESatZEVm18ueJmcpPep9+t15kneNh/H2bsj
         hO/i3xcRQLhmMJ1NoaOrqac++TouPBh5pzjkztPUBbMANpyE3uceF1I/hN1okU6AK+sl
         L5kw==
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=X1ZsRY4cuA47wbDKVIZwgLn3Of/Ex/vbZno7DnbIXtQ=;
        b=YhnYa/q0DV3aqg3nyfk0Yst41xgDr/0Ap7i1F1sdxrijPHIn0b5mpYrCJhI2Kf6oed
         lzBEDwyuhjRkAzPck3WLqOBXC9a86B4pO5mqyHag1Rm+B+imDMYmW9yZXpte9ptU7qIY
         aFJy9S2/yruP3Nib4+WH3U2+68yo+JdJpMbJUktVgfQqZSKcFpxU/RZl9PGkQ+WNLemS
         IaWFBRWHZ++Qamh/eI7FG2fcGUZa+h022LDYvihlc+v4rK1XySHkF4+lexmXz9mpdAsS
         zSz+z0aVPS7MSMQkxM7HRTCdOycIf+YNurioxrvN5wBr7Rwh5j8wMWsjYs4GpmLDir1J
         J+wQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=be6Tm6vO;
       spf=pass (google.com: domain of adrian.hawryluk@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=adrian.hawryluk@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=X1ZsRY4cuA47wbDKVIZwgLn3Of/Ex/vbZno7DnbIXtQ=;
        b=FxhceY3r08EUJzxqChepLnqSVFkQ959/DP1Idn9iSdQjvGlu32ujFTVATQ0T20VOeP
         ICPBbNsvwmPd8GprHcxRUp4079sy7QI+/Y6lNrwP5uynyAJH6l37faJU9mU4l0Sung0f
         xCwFgZHRlBM+H2nLr2ZW8Xnfjkb8FaSifAVy5F9Kx0UR8/CLpQAtVLngDinKSfA6BKrj
         jAxh6OQnubdTd0NZH9iJDJ+R6F2oZspalvay1/arbHsrvcwM5tMlNTqPxZv/DtqNOHNO
         f5CRipeTqlL0B8IdbubuhWzXbTjDh6jzPMCJ0wsqnLkywHy2AUpo1lsMJj3A+jvotZds
         ceIw==
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=X1ZsRY4cuA47wbDKVIZwgLn3Of/Ex/vbZno7DnbIXtQ=;
        b=PJ2O8FYK+1Lqa4LKHi8pCcRW+gQnlzMgY1o99XgUTdTKXNf8C+uy4LVanBS/CeStSF
         NHPh1J543a0JQUALdrIXMWs7SSUXtapYdZYgT1jiaiv1p7DHKK0AArkGgOQiuXikRcgS
         59aJ4Nn366Z7gBZ9YqKIgFpczi+DNn37paOVdYtD7MDJdM1fPUrFpkmGWSRgsOWPmZyI
         LURGNZnpp51ZQAyi5YGUFpSGeMYhQDxCw3dsmp3wShGudlyzqZMPi63SVtltV+zvseMJ
         bO6/BGg7HDGciSi5N83k3L5YsL1YVniOu59zSg76I/rqo8JJCxciREDVcs3tCYNSaGfa
         xKIg==
X-Gm-Message-State: ABuFfojiricNnxqQXZ8WNubpK1sPQN1C0ItnWEozkto71RTjI23zvQyu
	pOG/LFp0Wm2EbpidpA+psr2lDA==
X-Google-Smtp-Source: ACcGV609DhzhzW0Nippo24clbbRr6apFWgXhyiDRC7Pt5+2VWopnmhVSc5AClutM4zbicqM7QfupbA==
X-Received: by 2002:a19:4f43:: with SMTP id a3-v6mr413694lfk.2.1538086062239;
        Thu, 27 Sep 2018 15:07:42 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a19:ec14:: with SMTP id b20-v6ls537929lfa.10.gmail; Thu, 27
 Sep 2018 15:07:40 -0700 (PDT)
X-Received: by 2002:a19:cc97:: with SMTP id c145-v6mr8867263lfg.145.1538086060079;
        Thu, 27 Sep 2018 15:07:40 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1538086060; cv=none;
        d=google.com; s=arc-20160816;
        b=kkU6PsxzIfj6PFFBwSowbAY5s2/vLDjNcyDT3/SiM8gNQViKZjncqZ3Xwx4Gut/HeY
         Et52h/u144QvT2AguZXzGfTjzE8iyfaT2/VD0f1GLbMsk/KGqL/6TEAk7qHZNhztYHR1
         kVGIKST5VymXfcomPjwxgvBARvpDWtv8Dml804MNGcGxC9F+qCBYwFyqAOZTyzrAFZ+6
         2ELfqgNNEw7pS/hkkLmk5Zhh4vKZ/0sWxHVnIO7KlXS3Dm+Qw2SP3luRf4eTi9B908Uy
         KxnSoBwbFppF3gN1+ilzCEawfboXFncrRT6rrtAKFk0LQVgXn9pk6/Qxd4WIz08DrNsZ
         uZpg==
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=GpPHVGw16PlsMn97KSJXs2sI0CdB8vo/af6M+6uitvM=;
        b=Q1ZVobGUfVQNorOFIDbitzNzY1AdZO/AAtHyxVsQYM5/lNbmJnfi2W/PVUejzE/NrF
         Ukhinf0KaEBk+xm27xmfPnUWbIZbpDwQEiLgyQq8Yntrp4wHyKwwGqF2I1ZRztxhI3FQ
         8tgTOQuYPlTfDAvYYhpyq+i093QM/Ngb+Dorvp7BSkWRGm6zjJ2lovYM8YOgy6PjSnxh
         thCdqFZ4NPxgexeZ6BeXJ5tntcAmLjxE1qeSbMlDmSyszpO1B3Y7c3FuzOZzPvQgK1zB
         pzJTt5X5ln9Y2Sc0tLlH/QjMCu7ew0MU5GRmiYylp3r4l8p9w7kEAG5lXkYV4OtB5iS8
         rPWg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=be6Tm6vO;
       spf=pass (google.com: domain of adrian.hawryluk@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=adrian.hawryluk@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 y65-v6sor2080880lje.34.2018.09.27.15.07.40
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Thu, 27 Sep 2018 15:07:40 -0700 (PDT)
Received-SPF: pass (google.com: domain of adrian.hawryluk@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a2e:93c4:: with SMTP id p4-v6mr8817097ljh.150.1538086059358;
 Thu, 27 Sep 2018 15:07:39 -0700 (PDT)
In-Reply-To: <CAOHCbis2t0Dboe3+M23gS9i8zW4+LFWzM9PfTGmkiGUKEQ+BGQ@mail.gmail.com>
X-Original-Sender: adrianh.bsc@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=be6Tm6vO;       spf=pass
 (google.com: domain of adrian.hawryluk@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=adrian.hawryluk@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:40236
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40236>

--00000000000033bee00576e19156
Content-Type: text/plain; charset="UTF-8"

I guess this could also be done with operator overloading.  Something like:

#include <iostream>
#include <type_traits>

template<typename T>
struct chain_impl {
  chain_impl(T&& obj, bool val) : obj(std::move(obj)), val(val) {}
  T&& obj;
  bool val;
  explicit operator bool() {
      return val;
  }
};

template<typename T>
struct chain_impl<T&> {
  chain_impl(T& obj, bool val) : obj(obj), val(val) {}
  T& obj;
  bool val;
  explicit operator bool() {
      return val;
  }
};

template <typename T>
decltype(auto) make_chain(T&&  obj, bool val = true) {
  return chain_impl<std::conditional_t<std::is_lvalue_reference<T>::value,
T&, T&&>>(std::forward<T>(obj), val);
}

template <typename T0, typename T1>
auto operator< (chain_impl<T0>&& lhs, T1&& rhs) {
    if (lhs.val) {
        auto result = make_chain(rhs, lhs.obj < rhs);
        return make_chain(std::forward<T1>(rhs), lhs.val && result.val);
    }
    return make_chain(std::forward<T1>(rhs), false);
}

int main()
{
  std::cout << (make_chain(1) < 2 < 3 ? 1 : 0) << "\n";
  int a=1, b=2, c=3;
  std::cout << (make_chain(a) < c < b ? 1 : 0) << "\n";
}

But that will do extra trivial comparisons even if the test could be short
circuited, which is unfortunate.

A

On Thu, Sep 27, 2018 at 1:47 PM Tony V E <tvaneerd@gmail.com> wrote:

>
>
> Darn, I meant std::between(x, 100, -100);
>
> On Thu, Sep 27, 2018 at 1:47 PM Tony V E <tvaneerd@gmail.com> wrote:
>
>> We could argue about the order of params, and what std::between(x, -100,
>> 0) means, or you could look at std::clamp().
>>
>> On Thu, Sep 27, 2018 at 11:53 AM 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>
>>> .
>>>
>>
>>
>> --
>> Be seeing you,
>> Tony
>>
>
>
> --
> Be seeing you,
> Tony
>
> --
> 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/CAOHCbis2t0Dboe3%2BM23gS9i8zW4%2BLFWzM9PfTGmkiGUKEQ%2BBGQ%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbis2t0Dboe3%2BM23gS9i8zW4%2BLFWzM9PfTGmkiGUKEQ%2BBGQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
========================================
            Adrian Hawryluk
         BSc. Computer Science
----------------------------------------
           Specialising in:
        OOD Methodologies in UML
  OOP Methodologies in C, C++ and more
        RT Embedded Programming
            GUI Development
========================================

-- 
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/CAP_kE8VspyrrEkbrPNqbhN%3DJEzAw2BGtgvSWTYQWvEh%3D2F0CFw%40mail.gmail.com.

--00000000000033bee00576e19156
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">I guess this could also be done with oper=
ator overloading.=C2=A0 Something like:<div><br></div><div><div><font face=
=3D"monospace, monospace">#include &lt;iostream&gt;</font></div><div><font =
face=3D"monospace, monospace">#include &lt;type_traits&gt;</font></div><div=
><font face=3D"monospace, monospace"><br></font></div><div><font face=3D"mo=
nospace, monospace">template&lt;typename T&gt;</font></div><div><font face=
=3D"monospace, monospace">struct chain_impl {</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 chain_impl(T&amp;&amp; obj, bool val) : ob=
j(std::move(obj)), val(val) {}</font></div><div><font face=3D"monospace, mo=
nospace">=C2=A0 T&amp;&amp; obj;</font></div><div><font face=3D"monospace, =
monospace">=C2=A0 bool val;</font></div><div><font face=3D"monospace, monos=
pace">=C2=A0 explicit operator bool() {</font></div><div><font face=3D"mono=
space, monospace">=C2=A0 =C2=A0 =C2=A0 return val;</font></div><div><font f=
ace=3D"monospace, monospace">=C2=A0 }</font></div><div><font face=3D"monosp=
ace, monospace">};</font></div><div><font face=3D"monospace, monospace"><br=
></font></div><div><font face=3D"monospace, monospace">template&lt;typename=
 T&gt;</font></div><div><font face=3D"monospace, monospace">struct chain_im=
pl&lt;T&amp;&gt; {</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 chain_impl(T&amp; obj, bool val) : obj(obj), val(val) {}</font></div><d=
iv><font face=3D"monospace, monospace">=C2=A0 T&amp; obj;</font></div><div>=
<font face=3D"monospace, monospace">=C2=A0 bool val;</font></div><div><font=
 face=3D"monospace, monospace">=C2=A0 explicit operator bool() {</font></di=
v><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 return val;=
</font></div><div><font face=3D"monospace, monospace">=C2=A0 }</font></div>=
<div><font face=3D"monospace, monospace">};</font></div><div><font face=3D"=
monospace, monospace"><br></font></div><div><font face=3D"monospace, monosp=
ace">template &lt;typename T&gt;</font></div><div><font face=3D"monospace, =
monospace">decltype(auto) make_chain(T&amp;&amp;=C2=A0 obj, bool val =3D tr=
ue) {</font></div><div><font face=3D"monospace, monospace">=C2=A0 return ch=
ain_impl&lt;std::conditional_t&lt;std::is_lvalue_reference&lt;T&gt;::value,=
 T&amp;, T&amp;&amp;&gt;&gt;(std::forward&lt;T&gt;(obj), val);</font></div>=
<div><font face=3D"monospace, monospace">}</font></div><div><font face=3D"m=
onospace, monospace"><br></font></div><div><font face=3D"monospace, monospa=
ce">template &lt;typename T0, typename T1&gt;</font></div><div><font face=
=3D"monospace, monospace">auto operator&lt; (chain_impl&lt;T0&gt;&amp;&amp;=
 lhs, T1&amp;&amp; rhs) {</font></div><div><font face=3D"monospace, monospa=
ce">=C2=A0 =C2=A0 if (lhs.val) {</font></div><div><font face=3D"monospace, =
monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 auto result =3D make_chain(rhs, lhs.=
obj &lt; rhs);</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 return make_chain(std::forward&lt;T1&gt;(rhs), lhs.val=
 &amp;&amp; result.val);</font></div><div><font face=3D"monospace, monospac=
e">=C2=A0 =C2=A0 }</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 return make_chain(std::forward&lt;T1&gt;(rhs), false);</font></d=
iv><div><font face=3D"monospace, monospace">}</font></div><div><font face=
=3D"monospace, monospace"><br></font></div><div><font face=3D"monospace, mo=
nospace">int main()</font></div><div><font face=3D"monospace, monospace">{<=
/font></div><div><font face=3D"monospace, monospace">=C2=A0 std::cout &lt;&=
lt; (make_chain(1) &lt; 2 &lt; 3 ? 1 : 0) &lt;&lt; &quot;\n&quot;;</font></=
div><div><font face=3D"monospace, monospace">=C2=A0 int a=3D1, b=3D2, c=3D3=
;</font></div><div><font face=3D"monospace, monospace">=C2=A0 std::cout &lt=
;&lt; (make_chain(a) &lt; c &lt; b ? 1 : 0) &lt;&lt; &quot;\n&quot;;</font>=
</div><div><font face=3D"monospace, monospace">}</font></div></div><div><br=
></div><div><div>But that will do extra trivial comparisons even if the tes=
t could be short circuited, which is unfortunate.</div></div><div><br></div=
><div>A</div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On=
 Thu, Sep 27, 2018 at 1:47 PM Tony V E &lt;<a href=3D"mailto:tvaneerd@gmail=
..com">tvaneerd@gmail.com</a>&gt; wrote:<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"><div><br></div><div><br></div><div>Darn, I meant std:=
:between(x, 100, -100);<br></div></div><br><div class=3D"gmail_quote"><div =
dir=3D"ltr">On Thu, Sep 27, 2018 at 1:47 PM Tony V E &lt;<a href=3D"mailto:=
tvaneerd@gmail.com" target=3D"_blank">tvaneerd@gmail.com</a>&gt; wrote:<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">We could argue about =
the order of params, and what std::between(x, -100, 0) means, or you could =
look at std::clamp().<br></div><br><div class=3D"gmail_quote"><div dir=3D"l=
tr">On Thu, Sep 27, 2018 at 11:53 AM Addy &lt;<a href=3D"mailto:aclaure@gma=
il.com" target=3D"_blank">aclaure@gmail.com</a>&gt; wrote:<br></div><blockq=
uote 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 o=
ptional third (compare function) argument.</div><div><br></div><div>Similar=
 to this:=C2=A0<a href=3D"https://gist.github.com/martinmoene/9410391" targ=
et=3D"_blank">https://gist.github.com/martinmoene/9410391</a><br></div><div=
><br></div><div>templated&lt;typename T, typename Compare&gt;</div><div>boo=
l std::between(T lower, T upper, Compare comp)</div><div>{</div><div>=C2=A0=
 =C2=A0 return comp(lower) &amp;&amp; comp(upper);</div><div>}</div><div><b=
r></div><div>Does anything like this exist? Should I propose it!?</div></di=
v>

<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"><br>-- <br><div dir=3D"ltr" class=3D"m=
_-2593046207807963724gmail_signature" data-smartmail=3D"gmail_signature"><d=
iv dir=3D"ltr"><div>Be seeing you,<br></div>Tony<br></div></div></blockquot=
e></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"m_-259304620=
7807963724gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"l=
tr"><div>Be seeing you,<br></div>Tony<br></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/CAOHCbis2t0Dboe3%2BM23gS9i8zW4%2BLFWz=
M9PfTGmkiGUKEQ%2BBGQ%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Df=
ooter" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std=
-proposals/CAOHCbis2t0Dboe3%2BM23gS9i8zW4%2BLFWzM9PfTGmkiGUKEQ%2BBGQ%40mail=
..gmail.com</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">=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 Adrian Hawryluk<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 BSc. Computer Scie=
nce<br>----------------------------------------<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0=C2=A0 Specialising in:<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 OOD Method=
ologies in UML<br>=C2=A0 OOP Methodologies in C, C++ and more <br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 RT Embedded Programming<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 GUI Development<br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D</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/CAP_kE8VspyrrEkbrPNqbhN%3DJEzAw2BGtgv=
SWTYQWvEh%3D2F0CFw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAP_kE8Vspyrr=
EkbrPNqbhN%3DJEzAw2BGtgvSWTYQWvEh%3D2F0CFw%40mail.gmail.com</a>.<br />

--00000000000033bee00576e19156--

.
