220 40256 <bacc5cd9-230a-4865-858c-78566502cfef@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Adrian H <adrian.hawryluk@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::between ?
Date: Fri, 28 Sep 2018 08:18:05 -0700 (PDT)
Lines: 476
Approved: news@gmane.org
Message-ID: <bacc5cd9-230a-4865-858c-78566502cfef@isocpp.org>
References: <7b85d688-9013-407d-b7d3-10d28494e960@isocpp.org>
 <CAFdMc-36tAQ1JJxYOz3PEKv1qnGs=WPGN3NWWKCEwY+SgNdDXA@mail.gmail.com>
 <b917d650-33b0-459d-bba0-c0f03bc4db8d@isocpp.org> <CAFdMc-2=92DEL46jYrGPwESnUkwbYdrrWs=SfL3woc9A4H+6jQ@mail.gmail.com>
 <52d6bd1b-4afb-4f16-adde-8ee8b5ba1041@isocpp.org>
 <CAFdMc-3H6mrTgVNDe2ZGXmQ4WV9UQNv-EijJh=HnGHHHL7fh5w@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_132_735510085.1538147885385"
X-Trace: blaine.gmane.org 1538147765 1086 195.159.176.226 (28 Sep 2018 15:16:05 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 28 Sep 2018 15:16:05 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCULLOGNUQIRBLUMXHOQKGQEDNCTT3A@isocpp.org Fri Sep 28 17:16:01 2018
Return-path: <std-proposals+bncBCULLOGNUQIRBLUMXHOQKGQEDNCTT3A@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+bncBCULLOGNUQIRBLUMXHOQKGQEDNCTT3A@isocpp.org>)
	id 1g5uUn-00006n-0X
	for gclcip-std-proposals@m.gmane.org; Fri, 28 Sep 2018 17:15:57 +0200
Original-Received: by mail-yw1-f71.google.com with SMTP id q141-v6sf3699894ywg.5
        for <gclcip-std-proposals@m.gmane.org>; Fri, 28 Sep 2018 08:18:08 -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=7FVrJ8cYBg9JBPk93VhLYifXDZvXuzXrqutNk9kSoW4=;
        b=E9B0INfXOZcTOsIlj7fa0At/Xiu+5bgjMqVeABtXzElfAiGO9Je1ZYzPakfMN/cgUO
         lETid1M1yHTIF7hWqcPkm1bWGF5858N9jKCX0iB0jHnbgD+0BGHqT3/rD0qr224uOotO
         dJdC8hZqwEdKkcotA9qjFyQBxFKbOyve6WChbMDnazieLTk++HsSQGoKjwNK79AJgc7d
         dqzShlydk7Rc6CU74S9aesfr3FE739P/2AhfdsPMfKkWPrRNp+oCyKpX1knBL6jmL0q3
         YU2oiogkESDjOrsiFutiWDVo/aQN/pExKRBA1uPjHU/jPMdHXkBi2xyG0pcZqaFS3pbs
         VBFg==
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=7FVrJ8cYBg9JBPk93VhLYifXDZvXuzXrqutNk9kSoW4=;
        b=umpcbMbxfNwYgk5hihtyLNIQN5b7tuNG06aaTp5kQvLe2BDs/ezjunhQbdFdgXpREH
         WhbFmwGSpev0WwIdh/gh1rl3ZPLGLMrLLGICD6lfRox/hnsmNQZIZAr5v8nWekn12WcE
         9ALe6CgnoJjEYetlPSLpclRFv1OFeR8r467AtFWHw5f5wsdEwsuSQbsEAp6scG2y/9Gm
         HowtUuof2OK/Mjv0b/nwA/Lzww3fEMH424Ld6KnS7KhcFHuskG8e7aGlp2rq1EzIkGRm
         pCaWQ2clfIkvAbA+y2opd6roAwujez8GIG81XeipJY0djSePGy48tdJY5vdE9+T+n6tL
         ShRg==
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=7FVrJ8cYBg9JBPk93VhLYifXDZvXuzXrqutNk9kSoW4=;
        b=qPXqESUfDvDBgvKnWAbQ+cqE6r04VTf7V8iFt0woA2kNIs1RJZOBXZp4yt4683G3DV
         i79kabt9BWeLKnz/QkH4RLAq2LRMddvf/EUfF9THwo7nfcrlpUWceDvtxltB71+wz93M
         i8173aQ0zW61UTe4WARRQzv5AToaYVwFj1i+c6rG0SIegXbQfYpRKiUhuNVIse5wbN7n
         LTV8EkdOFfTa0OGyrJiKIsPUZn+JKFQBami1mzexIXtpSTkudx6g6yDNxphb5YQDSAAM
         IrFJr8AdVfG9NxhXPODOimTNcrZxoHPUibsNKLRdQzRMAU0qKxirsbXiIltGGU3hYo/Y
         sYZg==
X-Gm-Message-State: ABuFfohrPFu8jlXH8cBrFPgrMpIkidcK9IJGLgixdRF331n020aHrjWo
	AQwEmGtiKXsTcSnbiIWsbUjjYA==
X-Google-Smtp-Source: ACcGV61JMt93lh8uNXD+hCEJ3xs3j8fJl+jhDZx7Mg/rGRIjbuShOIXvQa7iu4FpAf53zNjBd6axDA==
X-Received: by 2002:a25:664f:: with SMTP id z15-v6mr5623273ybm.49.1538147887510;
        Fri, 28 Sep 2018 08:18:07 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:8b0c:: with SMTP id i12-v6ls2184095ybl.5.gmail; Fri, 28
 Sep 2018 08:18:06 -0700 (PDT)
X-Received: by 2002:a25:50c7:: with SMTP id e190-v6mr179846ybb.1.1538147886075;
        Fri, 28 Sep 2018 08:18:06 -0700 (PDT)
In-Reply-To: <CAFdMc-3H6mrTgVNDe2ZGXmQ4WV9UQNv-EijJh=HnGHHHL7fh5w@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:40256
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40256>

------=_Part_132_735510085.1538147885385
Content-Type: multipart/alternative; 
	boundary="----=_Part_133_1444313961.1538147885386"

------=_Part_133_1444313961.1538147885386
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



On Friday, September 28, 2018 at 10:53:35 AM UTC-4, Daniel Gutson wrote:
>
>
>
> El vie., 28 de sep. de 2018 a la(s) 11:40, Adrian H (adrian....@gmail.com=
=20
> <javascript:>) escribi=C3=B3:
>
>>
>>
>> On Friday, September 28, 2018 at 10:31:57 AM UTC-4, Daniel Gutson wrote:
>>>
>>>
>>>
>>> El vie., 28 sept. 2018 11:26, Jack Adrian Zappa <adrian....@gmail.com>=
=20
>>> escribi=C3=B3:
>>>
>>>>
>>>>
>>>> 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=20
>>>> solution would probably result in possible unnecessary comparisons (no=
=20
>>>> logical short circuiting)=20
>>>>
>>>
>>> No, the chain object contains a boolean and the last right hand operand=
=20
>>> as its only state. It should do nothing after the boolean becomes false=
..
>>>
>>
>> Could you provide your solution?  I'd be interested in finding out how=
=20
>> you dealt with short circuiting. =20
>>
>
> Sure, I'm in a conference but I will do later.
> =20
>
>> Also, I take it that your solution wouldn't allow comparisons of=20
>> different types such as a double and a float, or would it convert all=20
>> objects to the type of first one chained?=20
>>
>
> Both the chain class and the comparison operators are templates. The=20
> result of the operator is a new (temporal) chain object with the template=
=20
> argument deduced. Let me provide the code later.=20
>

Cool.  Still sounds very similar to what I posted:

#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 =3D true) {
  return chain_impl<std::conditional_t<std::is_lvalue_reference<T>::value,=
=20
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 =3D 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=3D1, b=3D2, c=3D3;
  std::cout << (make_chain(a) < c < b ? 1 : 0) << "\n";
}

Looking forward to seeing the difference.
=20

> =20
>
>>
>>
>>> and additional storage for bool propagation (though I've not looked at=
=20
>>>> what the optimizer would do).  Would prolly be better to implement in =
the=20
>>>> language to avoid those issues, even if it is only syntactic sugar, as=
 it=20
>>>> can make the code more readable.
>>>> =20
>>>>
>>>>>
>>>>>
>>>>> El jue., 27 de sep. de 2018 a la(s) 12:53, Addy (acl...@gmail.com)=20
>>>>> escribi=C3=B3:
>>>>>
>>>>>> I do this pattern often:
>>>>>>
>>>>>> if (0 < x && x < 100)
>>>>>>
>>>>>> And would love a simple `std::between()` that would take two=20
>>>>>> 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!?
>>>>>>
>>>>>> --=20
>>>>>> You received this message because you are subscribed to the Google=
=20
>>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,=20
>>>>>> send an email to std-proposal...@isocpp.org.
>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>> To view this discussion on the web visit=20
>>>>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d68=
8-9013-407d-b7d3-10d28494e960%40isocpp.org=20
>>>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d6=
88-9013-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=3Demail&utm_source=
=3Dfooter>
>>>>>> .
>>>>>>
>>>>>
>>>>>
>>>>> --=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=20
>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>>> an email to std-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> To view this discussion on the web visit=20
>>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b917d650-=
33b0-459d-bba0-c0f03bc4db8d%40isocpp.org=20
>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b917d650=
-33b0-459d-bba0-c0f03bc4db8d%40isocpp.org?utm_medium=3Demail&utm_source=3Df=
ooter>
>>>> .
>>>>
>>> --=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/52d6bd1b-4a=
fb-4f16-adde-8ee8b5ba1041%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/52d6bd1b-4=
afb-4f16-adde-8ee8b5ba1041%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/bacc5cd9-230a-4865-858c-78566502cfef%40isocpp.or=
g.

------=_Part_133_1444313961.1538147885386
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, September 28, 2018 at 10:53:35 AM UTC-4=
, Daniel Gutson wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">El vie., 28 de=
 sep. de 2018 a la(s) 11:40, Adrian H (<a href=3D"javascript:" target=3D"_b=
lank" gdf-obfuscated-mailto=3D"m1k1X0XWAAAJ" rel=3D"nofollow" onmousedown=
=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D=
&#39;javascript:&#39;;return true;">adrian....@gmail.com</a>) escribi=C3=B3=
:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><br>On Frida=
y, September 28, 2018 at 10:31:57 AM UTC-4, Daniel Gutson wrote:<blockquote=
 class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px =
#ccc solid;padding-left:1ex"><div dir=3D"auto"><div><br><br><div class=3D"g=
mail_quote"><div dir=3D"ltr">El vie., 28 sept. 2018 11:26, Jack Adrian Zapp=
a &lt;<a rel=3D"nofollow">adrian....@gmail.com</a>&gt; escribi=C3=B3:<br></=
div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><br>On Friday, Sept=
ember 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;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 solved is by creating a temporal object that allo=
ws 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><d=
iv>So, something similar to the solution I provided?=C2=A0 As I said, that =
solution would probably result in possible unnecessary comparisons (no logi=
cal short circuiting) </div></div></blockquote></div></div><div dir=3D"auto=
"><br></div><div dir=3D"auto">No, the chain object contains a boolean and t=
he last right hand operand as its only state. It should do nothing after th=
e boolean becomes false.</div></div></blockquote><div><br></div><div>Could =
you provide your solution?=C2=A0 I&#39;d be interested in finding out how y=
ou dealt with short circuiting.=C2=A0 </div></div></blockquote><div><br></d=
iv><div>Sure, I&#39;m in a conference but I will do later.</div><div>=C2=A0=
</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"><div>Also, I take it =
that your solution wouldn&#39;t allow comparisons of different types such a=
s a double and a float, or would it convert all objects to the type of firs=
t one chained?=C2=A0</div></div></blockquote><div><br></div><div>Both the c=
hain class and the comparison operators are templates. The result of the op=
erator is a new (temporal) chain object with the template argument deduced.=
 Let me provide the code later.=C2=A0</div></div></div></blockquote><div><b=
r></div><div>Cool.=C2=A0 Still sounds very similar to what I posted:</div><=
div><br></div><div><font face=3D"monospace, monospace">#include &lt;iostrea=
m&gt;</font></div><div><font face=3D"monospace, monospace">#include &lt;typ=
e_traits&gt;</font></div><div><font face=3D"monospace, monospace"><br></fon=
t></div><div><font face=3D"monospace, 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) : obj(std::move(obj)), val(val) {}</font></div><div><=
font face=3D"monospace, monospace">=C2=A0 T&amp;&amp; obj;</font></div><div=
><font face=3D"monospace, monospace">=C2=A0 bool val;</font></div><div><fon=
t face=3D"monospace, monospace">=C2=A0 explicit operator bool() {</font></d=
iv><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, monos=
pace">template&lt;typename T&gt;</font></div><div><font face=3D"monospace, =
monospace">struct chain_impl&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><div><font face=3D"monospace, monospace">=C2=A0 T&a=
mp; obj;</font></div><div><font face=3D"monospace, monospace">=C2=A0 bool v=
al;</font></div><div><font face=3D"monospace, monospace">=C2=A0 explicit op=
erator bool() {</font></div><div><font face=3D"monospace, monospace">=C2=A0=
 =C2=A0 =C2=A0 return val;</font></div><div><font face=3D"monospace, monosp=
ace">=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, monospace">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 true) {</font></div><div><font face=3D"monospace, =
monospace">=C2=A0 return chain_impl&lt;std::conditional_t&lt;<wbr>std::is_l=
value_reference&lt;T&gt;::<wbr>value, T&amp;, T&amp;&amp;&gt;&gt;(std::forw=
ard&lt;T&gt;(obj), val);</font></div><div><font face=3D"monospace, monospac=
e">}</font></div><div><font face=3D"monospace, monospace"><br></font></div>=
<div><font face=3D"monospace, monospace">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><d=
iv><font face=3D"monospace, monospace">=C2=A0 =C2=A0 if (lhs.val) {</font><=
/div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 a=
uto result =3D make_chain(rhs, lhs.obj &lt; rhs);</font></div><div><font fa=
ce=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return make_chain(s=
td::forward&lt;T1&gt;(<wbr>rhs), lhs.val &amp;&amp; result.val);</font></di=
v><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 }</font></div><div=
><font face=3D"monospace, monospace">=C2=A0 =C2=A0 return make_chain(std::f=
orward&lt;T1&gt;(<wbr>rhs), false);</font></div><div><font face=3D"monospac=
e, monospace">}</font></div><div><font face=3D"monospace, monospace"><br></=
font></div><div><font face=3D"monospace, monospace">int main()</font></div>=
<div><font face=3D"monospace, monospace">{</font></div><div><font face=3D"m=
onospace, monospace">=C2=A0 std::cout &lt;&lt; (make_chain(1) &lt; 2 &lt; 3=
 ? 1 : 0) &lt;&lt; &quot;\n&quot;;</font></div><div><span style=3D"font-fam=
ily: monospace, monospace;">=C2=A0 int a=3D1, b=3D2, c=3D3;</span><br></div=
><div><font face=3D"monospace, monospace">=C2=A0 std::cout &lt;&lt; (make_c=
hain(a) &lt; c &lt; b ? 1 : 0) &lt;&lt; &quot;\n&quot;;</font></div><div><s=
pan style=3D"font-family: monospace, monospace;">}</span></div><div><br></d=
iv><div>Looking forward to seeing the difference.</div><div>=C2=A0</div><bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div class=3D"gm=
ail_quote"><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"=
><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-=
left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"auto"><=
div dir=3D"auto"><br></div><div dir=3D"auto"><div class=3D"gmail_quote"><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>and additional storage fo=
r bool propagation (though I&#39;ve not looked at what the optimizer would =
do).=C2=A0 Would prolly be better to implement in the language to avoid tho=
se issues, even if it is only syntactic sugar, as it can make the code more=
 readable.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D=
"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv 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, Addy (<a rel=3D"nofollo=
w noreferrer">acl...@gmail.com</a>) escribi=C3=B3:<br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr">I do this pattern often:<div><br></div><di=
v>if (0 &lt; x &amp;&amp; x &lt; 100)</div><div><br></div><div>And would lo=
ve a simple `std::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" rel=3D"nofol=
low" target=3D"_blank" onmousedown=3D"this.href=3D&#39;https://www.google.c=
om/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fmartinmoene%2F9410391\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A&#39;;return tru=
e;" 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\x=
3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A&#39;;return true;">https://gist.github=
..com/<wbr>martinmoene/9410391</a><br></div><div><br></div><div>templated&lt=
;typename T, typename Compare&gt;</div><div>bool std::between(T lower, T up=
per, Compare comp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lower) &=
amp;&amp; comp(upper);</div><div>}</div><div><br></div><div>Does anything l=
ike 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 rel=3D"nofollow noreferrer">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow noreferrer">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/<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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</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&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/b917d650-33b0-459d-bba0-c0f03bc4db8d%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/b917d650-33b0-459d-bba0-c0f03bc4db8d%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/b917d650-33b0-459d-<wbr>bba0-=
c0f03bc4db8d%40isocpp.org</a><wbr>.<br>
</blockquote></div></div></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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
m1k1X0XWAAAJ" 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"m1k1X0XWAAAJ" 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/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%=
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/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%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/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%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/52d6bd1b-4afb-4f16-<wbr>adde-=
8ee8b5ba1041%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></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/bacc5cd9-230a-4865-858c-78566502cfef%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bacc5cd9-230a-4865-858c-78566502cfef=
%40isocpp.org</a>.<br />

------=_Part_133_1444313961.1538147885386--

------=_Part_132_735510085.1538147885385--

.
