220 40259 <CAFdMc-0wDSKSAGQFoj4GSBFyp1fD4jC4A_LrMw3k4=nj2jBRgQ@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 12:25:16 -0300
Lines: 506
Approved: news@gmane.org
Message-ID: <CAFdMc-0wDSKSAGQFoj4GSBFyp1fD4jC4A_LrMw3k4=nj2jBRgQ@mail.gmail.com>
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>
 <bacc5cd9-230a-4865-858c-78566502cfef@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="000000000000b9c1560576f010f8"
X-Trace: blaine.gmane.org 1538148205 1517 195.159.176.226 (28 Sep 2018 15:23:25 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 28 Sep 2018 15:23:25 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDE3NBMV6UFBB2MPXHOQKGQEG5UGHAY@isocpp.org Fri Sep 28 17:23:20 2018
Return-path: <std-proposals+bncBDE3NBMV6UFBB2MPXHOQKGQEG5UGHAY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lj1-f197.google.com ([209.85.208.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDE3NBMV6UFBB2MPXHOQKGQEG5UGHAY@isocpp.org>)
	id 1g5ubv-0000Gm-Oq
	for gclcip-std-proposals@m.gmane.org; Fri, 28 Sep 2018 17:23:19 +0200
Original-Received: by mail-lj1-f197.google.com with SMTP id c16-v6sf1864788lja.20
        for <gclcip-std-proposals@m.gmane.org>; Fri, 28 Sep 2018 08:25:30 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1538148330; cv=pass;
        d=google.com; s=arc-20160816;
        b=wuHJmzMXfS1pBy4/BuFEMfWWUxog0tR4wvDFJ/w6OHM2FJv8RSsv07raQ+SvtE8fOa
         fQ4d8ZQ8PrFtFGg4ZQpxJ2ZIHJMXJX6r3yvHCVGL+z6eC+IXhfarTcLeEXBih+7SvTv9
         +HsQEYuq14IqQZOVD/qYIt2yr8v5ILWk624z3Tjqhs8RuX23y03Ia22WzZqlzV5j1HPo
         8Eum3H8oCUN/t9WnlYDpRpCaB6hjBWxGsRH1sZseaLpFicBGChFezFj7BnFmfDhQq5Yg
         T2zt3bb94i7kxzhjwJQ5zqLOzqaei5BxBIF7QuuE7RjSnuiy+hW4DrrO9cMCc0H5cse0
         SJ2Q==
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=0Itedh41+sv3aYGX0GZjZg7XzG8jGdYW24iyGS7qDF4=;
        b=Orvgqg8SP8+vGqs1dk5KzSY3me4ZDAVfjXz1kx3XI6V161QFFnhxCAcjvaSCs4398V
         BO3AvtpLu6Pp0/HwDjsFvcBCB813w/ClyEr/CxJCjOo/V0S/4gQp7AjRuvchjZMLgUNx
         TB5x9QNg0Jl3D09SPmMjZxAVY5Cg4zOD3viQGDGOyLMhbhWdzm/VXpwit/OLKzEWawGF
         2b0Xu52WFQndupPhtPPcoIwAmVrkzf6q5QApdt6fyT1Xu04RVwYRutfjoCXsM5O4Ni82
         clYcpyMuRp5CUTAv37eWqbEPRGsBgNy0VUSANsks7MW54O8JgfQYfmDvTzhICYHzTzkJ
         Xg5w==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=EVrVJWvx;
       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=0Itedh41+sv3aYGX0GZjZg7XzG8jGdYW24iyGS7qDF4=;
        b=DAkV7QWq84KZtFOH5DA0n5fQgg5lavnHwRdWEybwocBCg7KfnhPShSj5RFyPLJefSI
         vtvlo9BWX3F7woXHb4brD+N7l0ddvcNUyYEof5XYjCLItZPHkavPkWI8yTzfDUDAkucJ
         ctSwhQdatEtC5gde0dXETLLroQBF3qTwWAB58KKZkQtvplOJmILm3vXvhNVW/cppOIEY
         MdhiJan0156AmFuDnDk3c1+aGaJO67savQ5cSJZ0uDCOEJ4rCAdUA2za66WR8CT+FX0g
         ME4MydH9b4n6kBBbtn7e/+OPTc1ac2DdVZ+NwNRxQcy+OWPRz5hDadbEL+1JuofkyMXV
         Fd/A==
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=0Itedh41+sv3aYGX0GZjZg7XzG8jGdYW24iyGS7qDF4=;
        b=dicCVoZkxrabpZ8w2LWIMDY6GUIBlxnXru8CeIWcyntCISBJ4K3RysOOq4O2Nu+J+A
         jRzGNlVA8ry6w0IvTsJirY5eJwv+0xkPjTjIrwzSgjF4tVK0QdF5w9Z+IcEQoV5w09dv
         Gxas4GC1XbaD87CcOMYZCRqzhMeavZp9zadRFH169S8LPmqxsZTKUNCJ8gs9tXupDlvN
         tljTAsbTFvSJRlA6qDx9IZ9tJXX0S7BvM8jb4TfNqPC0epL9CX7z0MDGM3tkQ88EdwC4
         F5IS4NN5M1i3q+SN5nVUUdPJ4HmALpECRaJesmh3d2Fam6bO6k82tejnWIrWnYypQ60c
         6ADg==
X-Gm-Message-State: ABuFfohBrDjZ6N9pgN+m47OxYPfDGZevW0+fKyQBov6+fPSsUXJfmXNU
	N92ZjDifLUIU1HPcu41TN5073A==
X-Google-Smtp-Source: ACcGV63hv7WP8ojLqgVc/v2Ox/9SGfyY8tGISwlAh/zjal7pYCaY2OrOMShhLOEkIOxN0wXW4rt5MA==
X-Received: by 2002:a19:ca5a:: with SMTP id h26-v6mr221288lfj.4.1538148330205;
        Fri, 28 Sep 2018 08:25:30 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a2e:98d4:: with SMTP id s20-v6ls1086465ljj.3.gmail; Fri, 28
 Sep 2018 08:25:29 -0700 (PDT)
X-Received: by 2002:a2e:9606:: with SMTP id v6-v6mr11816012ljh.94.1538148329125;
        Fri, 28 Sep 2018 08:25:29 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1538148329; cv=none;
        d=google.com; s=arc-20160816;
        b=iAqNcRaZj3lolEa52xgH/QyNAAGM5yWSGyYCrmFLS1TGdeEckB7TI1qv8Kk8+hOxGo
         TsxfQp/Tq0KJiyvGdFD9kABGtbW+Y4Qg6ar+QCqP+t49iaMVs8Jh96ar/vvA5WYU86Rc
         DXPUgWyea34x1I+eqEt1PgQHQKz55HzMNV88QDLKcEDfu4Hogq3ipQPZautgs5BL+2lU
         UaXm72KZDE38X3Cl7Tw8WDCi9fFJlK1Xzpulyv/3m3RWZfXENluOcPDQbf/2uFUx/tQX
         Fhp+mpb+kMF2x2qWd+tPZLs4F/SwIIYxkf1rgmhW6P2h4hgUSLiow5oY/HgVAmW4SJcH
         71Aw==
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=R3IZeEjF4JL078Nq9YoNpzBp4rOLlidQSy86iZ38wO4=;
        b=P2Ww75e89knwB7UVLWWFAPnKWyfrohEtoGinyPN3k8JD7iScHPhJp16Qg+E5fR68e6
         xL0UVLXEF9PUNkqsmxAICFYSMeICorCueO5oJEjwa4qLkgYBTbOMFrGK1H+LsfjIAoba
         zyRW3JZhbZeJabMKM+bf1lcOX27ijJinHXps4Jpf1Cj7bgxHqqTGvLRjWHygbaPDEogv
         TIK8OmvzjjZqPKal9BT/E5bnCaV4pi3YOW0AgfieVNAKtRUGcBRvFaH6t/Ltf3gqWr+J
         jvpoVy87zMIHrOKTZHU8qmB6EOzAgXA56wu6ijRA4BQYbQHL8fdNAIiy4SQYfoksZz22
         6mdQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=EVrVJWvx;
       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 y62-v6sor2335322lfd.14.2018.09.28.08.25.29
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Fri, 28 Sep 2018 08:25:29 -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:a19:5e5d:: with SMTP id z29-v6mr10469621lfi.110.1538148328388;
 Fri, 28 Sep 2018 08:25:28 -0700 (PDT)
In-Reply-To: <bacc5cd9-230a-4865-858c-78566502cfef@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=EVrVJWvx;       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:40259
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40259>

--000000000000b9c1560576f010f8
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

El vie., 28 de sep. de 2018 a la(s) 12:18, Adrian H (
adrian.hawryluk@gmail.com) escribi=C3=B3:

>
>
> 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.co=
m)
>> 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>
>>>> escribi=C3=B3:
>>>>
>>>>>
>>>>>
>>>>> On Friday, September 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrot=
e:
>>>>>>
>>>>>> 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)
>>>>>>
>>>>>
>>>>> So, something similar to the solution I provided?  As I said, that
>>>>> solution would probably result in possible unnecessary comparisons (n=
o
>>>>> logical short circuiting)
>>>>>
>>>>
>>>> No, the chain object contains a boolean and the last right hand operan=
d
>>>> as its only state. It should do nothing after the boolean becomes fals=
e.
>>>>
>>>
>>> Could you provide your solution?  I'd be interested in finding out how
>>> you dealt with short circuiting.
>>>
>>
>> Sure, I'm in a conference but I will do later.
>>
>>
>>> Also, I take it that your solution wouldn't allow comparisons of
>>> different types such as a double and a float, or would it convert all
>>> objects to the type of first one chained?
>>>
>>
>> Both the chain class and the comparison operators are templates. The
>> result of the operator is a new (temporal) chain object with the templat=
e
>> argument deduced. Let me provide the code later.
>>
>
> Cool.  Still sounds very similar to what I posted:
>

Actually it is now that I read it more carefully:


>
> #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=
,
> T&, T&&>>(std::forward<T>(obj), val);
> }
>
> template <typename T0, typename T1>
> auto operator< (chain_impl<T0>&& lhs, T1&& rhs) {
>     if (lhs.val) {
>

Why you say that comparisons are performed? You are breaking the chain here
with this evaluation. So yes, operator will keep be called, but it's just
this if.


>         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.
>
>
>>
>>
>>>
>>>
>>>> and additional storage for bool propagation (though I've not looked at
>>>>> what the optimizer would do).  Would prolly be better to implement in=
 the
>>>>> language to avoid those issues, even if it is only syntactic sugar, a=
s it
>>>>> can make the code more readable.
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>> El jue., 27 de sep. de 2018 a la(s) 12:53, Addy (acl...@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 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-proposal...@isocpp.org.
>>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d6=
88-9013-407d-b7d3-10d28494e960%40isocpp.org
>>>>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d=
688-9013-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=3Demail&utm_source=
=3Dfooter>
>>>>>>> .
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> 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?
>>>>>>
>>>>> --
>>>>> 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, sen=
d
>>>>> 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
>>>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b917d650=
-33b0-459d-bba0-c0f03bc4db8d%40isocpp.org
>>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b917d65=
0-33b0-459d-bba0-c0f03bc4db8d%40isocpp.org?utm_medium=3Demail&utm_source=3D=
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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit
>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/52d6bd1b-4=
afb-4f16-adde-8ee8b5ba1041%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/52d6bd1b-=
4afb-4f16-adde-8ee8b5ba1041%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>
>>> .
>>>
>>
>>
>> --
>> 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?
>>
> --
> 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/bacc5cd9-230=
a-4865-858c-78566502cfef%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/bacc5cd9-23=
0a-4865-858c-78566502cfef%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-0wDSKSAGQFoj4GSBFyp1fD4jC4A_LrMw3k4%3Dnj2=
jBRgQ%40mail.gmail.com.

--000000000000b9c1560576f010f8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<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) 12:18, Adrian H (<a href=3D"mailto:adrian.haw=
ryluk@gmail.com">adrian.hawryluk@gmail.com</a>) escribi=C3=B3:<br></div><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"><br><br>On Friday, September 2=
8, 2018 at 10:53:35 AM UTC-4, Daniel Gutson wrote:<blockquote class=3D"gmai=
l_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pad=
ding-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 rel=3D"nof=
ollow">adrian....@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;padd=
ing-left:1ex"><div dir=3D"ltr"><br><br>On Friday, 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"gmail_quote"><div dir=3D"ltr"=
>El vie., 28 sept. 2018 11:26, Jack Adrian Zappa &lt;<a rel=3D"nofollow">ad=
rian....@gmail.com</a>&gt; escribi=C3=B3:<br></div><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><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"marg=
in:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div di=
r=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 solv=
ed is by creating a temporal object that allows chain comparison, and a cas=
t-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) </div></=
div></blockquote></div></div><div dir=3D"auto"><br></div><div dir=3D"auto">=
No, the chain object contains a boolean and the last right hand operand as =
its only state. It should do nothing after the 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 you dealt with short circuitin=
g.=C2=A0 </div></div></blockquote><div><br></div><div>Sure, I&#39;m in a co=
nference but I will do later.</div><div>=C2=A0</div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr"><div>Also, I take it that your solution wouldn&#39=
;t allow comparisons of different types such as a double and a float, or wo=
uld it convert all objects to the type of first one chained?=C2=A0</div></d=
iv></blockquote><div><br></div><div>Both the chain class and the comparison=
 operators are templates. The result of the operator is a new (temporal) ch=
ain object with the template argument deduced. Let me provide the code late=
r.=C2=A0</div></div></div></blockquote><div><br></div><div>Cool.=C2=A0 Stil=
l sounds very similar to what I posted:</div></div></blockquote><div><br></=
div><div>Actually it is now that I read it more carefully:</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><br></div><div><=
font face=3D"monospace, monospace">#include &lt;iostream&gt;</font></div><d=
iv><font face=3D"monospace, monospace">#include &lt;type_traits&gt;</font><=
/div><div><font face=3D"monospace, monospace"><br></font></div><div><font f=
ace=3D"monospace, monospace">template&lt;typename T&gt;</font></div><div><f=
ont face=3D"monospace, monospace">struct chain_impl {</font></div><div><fon=
t 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"monospa=
ce, monospace">=C2=A0 T&amp;&amp; obj;</font></div><div><font face=3D"monos=
pace, monospace">=C2=A0 bool val;</font></div><div><font face=3D"monospace,=
 monospace">=C2=A0 explicit operator bool() {</font></div><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, mono=
space"><br></font></div><div><font face=3D"monospace, monospace">template&l=
t;typename T&gt;</font></div><div><font face=3D"monospace, monospace">struc=
t chain_impl&lt;T&amp;&gt; {</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 chain_impl(T&amp; obj, bool val) : obj(obj), val(val) {}</fon=
t></div><div><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></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 r=
eturn val;</font></div><div><font face=3D"monospace, monospace">=C2=A0 }</f=
ont></div><div><font face=3D"monospace, monospace">};</font></div><div><fon=
t face=3D"monospace, monospace"><br></font></div><div><font face=3D"monospa=
ce, monospace">template &lt;typename T&gt;</font></div><div><font face=3D"m=
onospace, 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;std::is_lvalue_reference&lt;T&g=
t;::value, T&amp;, T&amp;&amp;&gt;&gt;(std::forward&lt;T&gt;(obj), val);</f=
ont></div><div><font face=3D"monospace, monospace">}</font></div><div><font=
 face=3D"monospace, monospace"><br></font></div><div><font face=3D"monospac=
e, monospace">template &lt;typename T0, typename T1&gt;</font></div><div><f=
ont face=3D"monospace, monospace">auto operator&lt; (chain_impl&lt;T0&gt;&a=
mp;&amp; lhs, T1&amp;&amp; rhs) {</font></div><div><font face=3D"monospace,=
 monospace">=C2=A0 =C2=A0 if (lhs.val) {</font></div></div></blockquote><di=
v><br></div><div>Why you say that comparisons are performed? You are breaki=
ng the chain here with this evaluation. So yes, operator will keep be calle=
d, but it&#39;s just this if.</div><div>=C2=A0</div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr"><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 auto result =3D make_chain(rhs, lhs.obj &lt; rhs);</fo=
nt></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; resul=
t.val);</font></div><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::forward&lt;T1&gt;(rhs), false);</font></div><div><font fac=
e=3D"monospace, monospace">}</font></div><div><font face=3D"monospace, mono=
space"><br></font></div><div><font face=3D"monospace, monospace">int main()=
</font></div><div><font face=3D"monospace, monospace">{</font></div><div><f=
ont 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><span styl=
e=3D"font-family: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;&l=
t; (make_chain(a) &lt; c &lt; b ? 1 : 0) &lt;&lt; &quot;\n&quot;;</font></d=
iv><div><span style=3D"font-family:monospace,monospace">}</span></div><div>=
<br></div><div>Looking forward to seeing the difference.</div><div>=C2=A0</=
div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"=
gmail_quote"><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r"><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0;margi=
n-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"><=
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>and additional storage =
for bool propagation (though I&#39;ve not looked at what the optimizer woul=
d do).=C2=A0 Would prolly be better to implement in the language to avoid t=
hose issues, even if it is only syntactic sugar, as it can make the code mo=
re 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"=
><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, Addy (<a rel=3D"nofo=
llow noreferrer">acl...@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 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 option=
al third (compare function) argument.</div><div><br></div><div>Similar to t=
his:=C2=A0<a href=3D"https://gist.github.com/martinmoene/9410391" rel=3D"no=
follow" target=3D"_blank">https://gist.github.com/martinmoene/9410391</a><b=
r></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; 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 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">https://groups.google.com/a/isocpp.org/d/msgid/std-proposa=
ls/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.org</a>.<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">https://groups.google.com/a/isocpp.org/d/msgid/std-proposa=
ls/b917d650-33b0-459d-bba0-c0f03bc4db8d%40isocpp.org</a>.<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 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/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-proposa=
ls/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%40isocpp.org</a>.<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" 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/bacc5cd9-230a-4865-858c-78566502cfef%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/bacc5cd9-230a-=
4865-858c-78566502cfef%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></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-0wDSKSAGQFoj4GSBFyp1fD4jC4A_Lr=
Mw3k4%3Dnj2jBRgQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-0wDSKSAG=
QFoj4GSBFyp1fD4jC4A_LrMw3k4%3Dnj2jBRgQ%40mail.gmail.com</a>.<br />

--000000000000b9c1560576f010f8--

.
