Topic: std::between ?
Author: Addy <aclaure@gmail.com>
Date: Thu, 27 Sep 2018 08:53:21 -0700 (PDT)
Raw View
------=_Part_380_506474107.1538063601171
Content-Type: multipart/alternative;
boundary="----=_Part_381_1840869567.1538063601171"
------=_Part_381_1840869567.1538063601171
Content-Type: text/plain; charset="UTF-8"
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.
------=_Part_381_1840869567.1538063601171
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I do this pattern often:<div><br></div><div>if (0 < x &=
amp;& x < 100)</div><div><br></div><div>And would love a simple `std=
::between()` that would take two arguments and an optional third (compare f=
unction) argument.</div><div><br></div><div>Similar to this:=C2=A0https://g=
ist.github.com/martinmoene/9410391<br></div><div><br></div><div>templated&l=
t;typename T, typename Compare></div><div>bool std::between(T lower, T u=
pper, Compare comp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lower) =
&& 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" 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/7b85d688-9013-407d-b7d3-10d28494e960%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7b85d688-9013-407d-b7d3-10d28494e960=
%40isocpp.org</a>.<br />
------=_Part_381_1840869567.1538063601171--
------=_Part_380_506474107.1538063601171--
.
Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Thu, 27 Sep 2018 17:07:10 +0100
Raw View
--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<b<c is e=
valuated as (a<b)<c, where (a<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'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 wa=
nt it, it'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,=
<<a href=3D"mailto:aclaure@gmail.com">aclaure@gmail.com</a>> 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 < x && x < 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<typename T,=
typename Compare></div><div>bool std::between(T lower, T upper, Compare=
comp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lower) && 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" 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&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" 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--
.
Author: "d25fe0be@outlook.com" <d25fe0be@outlook.com>
Date: Thu, 27 Sep 2018 16:19:11 +0000
Raw View
http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0893r1.html
--
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/HK2PR0301MB206541879B5E3DF8E50AB50E8B140%40HK2PR0301MB2065.apcprd03.prod.outlook.com.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Thu, 27 Sep 2018 13:47:11 -0400
Raw View
--00000000000065b7e50576ddeedc
Content-Type: text/plain; charset="UTF-8"
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
--
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/CAOHCbitYKvMhz1kkjZCk5Ep1vkFU9ZUwH7kZ%2Bm9_tyG%3DueEdcw%40mail.gmail.com.
--00000000000065b7e50576ddeedc
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">We could argue about the order of params, and what std::be=
tween(x, -100, 0) means, or you could look at std::clamp().<br></div><br><d=
iv class=3D"gmail_quote"><div dir=3D"ltr">On Thu, Sep 27, 2018 at 11:53 AM =
Addy <<a href=3D"mailto:aclaure@gmail.com">aclaure@gmail.com</a>> wro=
te:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I do this patt=
ern often:<div><br></div><div>if (0 < x && x < 100)</div><div=
><br></div><div>And would love a simple `std::between()` that would take tw=
o arguments and an optional third (compare function) argument.</div><div><b=
r></div><div>Similar to this:=C2=A0<a href=3D"https://gist.github.com/marti=
nmoene/9410391" target=3D"_blank">https://gist.github.com/martinmoene/94103=
91</a><br></div><div><br></div><div>templated<typename T, typename Compa=
re></div><div>bool std::between(T lower, T upper, Compare comp)</div><di=
v>{</div><div>=C2=A0 =C2=A0 return comp(lower) && comp(upper);</div=
><div>}</div><div><br></div><div>Does anything like this exist? Should I pr=
opose it!?</div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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&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"g=
mail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><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" 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/CAOHCbitYKvMhz1kkjZCk5Ep1vkFU9ZUwH7kZ=
%2Bm9_tyG%3DueEdcw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbitYKvMh=
z1kkjZCk5Ep1vkFU9ZUwH7kZ%2Bm9_tyG%3DueEdcw%40mail.gmail.com</a>.<br />
--00000000000065b7e50576ddeedc--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Thu, 27 Sep 2018 13:47:45 -0400
Raw View
--0000000000006774a60576ddf0fa
Content-Type: text/plain; charset="UTF-8"
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.
--0000000000006774a60576ddf0fa
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><br></div><div><br></div><div>Darn, I meant std::betw=
een(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 <<a href=3D"mailto:tva=
neerd@gmail.com">tvaneerd@gmail.com</a>> wrote:<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">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"ltr">On Thu, Sep 27, 2=
018 at 11:53 AM Addy <<a href=3D"mailto:aclaure@gmail.com">aclaure@gmail=
..com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"mar=
gin: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 < x && x <=
; 100)</div><div><br></div><div>And would love a simple `std::between()` th=
at would take two arguments and an optional third (compare function) argume=
nt.</div><div><br></div><div>Similar to this:=C2=A0<a href=3D"https://gist.=
github.com/martinmoene/9410391" target=3D"_blank">https://gist.github.com/m=
artinmoene/9410391</a><br></div><div><br></div><div>templated<typename T=
, typename Compare></div><div>bool std::between(T lower, T upper, Compar=
e comp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lower) && c=
omp(upper);</div><div>}</div><div><br></div><div>Does anything like this ex=
ist? 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" 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&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"g=
mail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div>Be=
seeing you,<br></div>Tony<br></div></div></blockquote></div><br clear=3D"a=
ll"><br>-- <br><div dir=3D"ltr" class=3D"gmail_signature" data-smartmail=3D=
"gmail_signature"><div dir=3D"ltr"><div>Be seeing you,<br></div>Tony<br></d=
iv></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/CAOHCbis2t0Dboe3%2BM23gS9i8zW4%2BLFWz=
M9PfTGmkiGUKEQ%2BBGQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbis2t0=
Dboe3%2BM23gS9i8zW4%2BLFWzM9PfTGmkiGUKEQ%2BBGQ%40mail.gmail.com</a>.<br />
--0000000000006774a60576ddf0fa--
.
Author: Adrian H <adrianh.bsc@gmail.com>
Date: Thu, 27 Sep 2018 18:07:27 -0400
Raw View
--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 <iostream></font></div><div><font =
face=3D"monospace, monospace">#include <type_traits></font></div><div=
><font face=3D"monospace, monospace"><br></font></div><div><font face=3D"mo=
nospace, monospace">template<typename T></font></div><div><font face=
=3D"monospace, monospace">struct chain_impl {</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 chain_impl(T&& obj, bool val) : ob=
j(std::move(obj)), val(val) {}</font></div><div><font face=3D"monospace, mo=
nospace">=C2=A0 T&& 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<typename=
T></font></div><div><font face=3D"monospace, monospace">struct chain_im=
pl<T&> {</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 chain_impl(T& obj, bool val) : obj(obj), val(val) {}</font></div><d=
iv><font face=3D"monospace, monospace">=C2=A0 T& 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 <typename T></font></div><div><font face=3D"monospace, =
monospace">decltype(auto) make_chain(T&&=C2=A0 obj, bool val =3D tr=
ue) {</font></div><div><font face=3D"monospace, monospace">=C2=A0 return ch=
ain_impl<std::conditional_t<std::is_lvalue_reference<T>::value,=
T&, T&&>>(std::forward<T>(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 <typename T0, typename T1></font></div><div><font face=
=3D"monospace, monospace">auto operator< (chain_impl<T0>&&=
lhs, T1&& 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 < rhs);</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 return make_chain(std::forward<T1>(rhs), lhs.val=
&& 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<T1>(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; (make_chain(1) < 2 < 3 ? 1 : 0) << "\n";</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 <=
;< (make_chain(a) < c < b ? 1 : 0) << "\n";</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 <<a href=3D"mailto:tvaneerd@gmail=
..com">tvaneerd@gmail.com</a>> 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 <<a href=3D"mailto:=
tvaneerd@gmail.com" target=3D"_blank">tvaneerd@gmail.com</a>> 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 <<a href=3D"mailto:aclaure@gma=
il.com" target=3D"_blank">aclaure@gmail.com</a>> 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 < x && x < 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<typename T, typename Compare></div><div>boo=
l std::between(T lower, T upper, Compare comp)</div><div>{</div><div>=C2=A0=
=C2=A0 return comp(lower) && 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" 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&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" 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&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" 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--
.
Author: Daniel Gutson <danielgutson@gmail.com>
Date: Fri, 28 Sep 2018 08:03:05 -0300
Raw View
--000000000000098e670576ec67a0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I stepped into this too many times.
One of the issues are the four < vs <=3D combinations.
The way I solved is by creating a temporal object that allows chain
comparison, and a cast-to-bool operator.
if (chain(3) < x < 4)
El jue., 27 de sep. de 2018 a la(s) 12:53, Addy (aclaure@gmail.com)
escribi=C3=B3:
> I do this pattern often:
>
> if (0 < x && x < 100)
>
> And would love a simple `std::between()` that would take two arguments an=
d
> an optional third (compare function) argument.
>
> Similar to this: https://gist.github.com/martinmoene/9410391
>
> templated<typename T, typename Compare>
> bool std::between(T lower, T upper, Compare comp)
> {
> return comp(lower) && comp(upper);
> }
>
> Does anything like this exist? Should I propose it!?
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-901=
3-407d-b7d3-10d28494e960%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-90=
13-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAFdMc-36tAQ1JJxYOz3PEKv1qnGs%3DWPGN3NWWKCEwY%2B=
SgNdDXA%40mail.gmail.com.
--000000000000098e670576ec67a0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I stepped into this too many times.<div>One of the issues =
are the four < vs <=3D combinations.</div><div><br></div><div>The way=
I solved is by creating a temporal object that allows chain comparison, an=
d a cast-to-bool operator.</div><div><br></div><div>if (chain(3) < x <=
; 4)=C2=A0<br></div><div><br></div><div><br></div></div><br><div class=3D"g=
mail_quote"><div dir=3D"ltr">El jue., 27 de sep. de 2018 a la(s) 12:53, Add=
y (<a href=3D"mailto:aclaure@gmail.com">aclaure@gmail.com</a>) escribi=C3=
=B3:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I do this pat=
tern often:<div><br></div><div>if (0 < x && x < 100)</div><di=
v><br></div><div>And would love a simple `std::between()` that would take t=
wo arguments and an optional third (compare function) argument.</div><div><=
br></div><div>Similar to this:=C2=A0<a href=3D"https://gist.github.com/mart=
inmoene/9410391" target=3D"_blank">https://gist.github.com/martinmoene/9410=
391</a><br></div><div><br></div><div>templated<typename T, typename Comp=
are></div><div>bool std::between(T lower, T upper, Compare comp)</div><d=
iv>{</div><div>=C2=A0 =C2=A0 return comp(lower) && comp(upper);</di=
v><div>}</div><div><br></div><div>Does anything like this exist? Should I p=
ropose it!?</div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-9013-=
407d-b7d3-10d28494e960%40isocpp.org</a>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
class=3D"gmail_signature" data-smartmail=3D"gmail_signature">Who=E2=80=99s=
got the sweetest disposition?<br>One guess, that=E2=80=99s who?<br>Who=E2=
=80=99d never, ever start an argument?<br>Who never shows a bit of temperam=
ent?<br>Who's never wrong but always right?<br>Who'd never dream of=
starting a fight?<br>Who get stuck with all the bad luck? </div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAFdMc-36tAQ1JJxYOz3PEKv1qnGs%3DWPGN3=
NWWKCEwY%2BSgNdDXA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-36tAQ1=
JJxYOz3PEKv1qnGs%3DWPGN3NWWKCEwY%2BSgNdDXA%40mail.gmail.com</a>.<br />
--000000000000098e670576ec67a0--
.
Author: Jack Adrian Zappa <adrian.hawryluk@gmail.com>
Date: Fri, 28 Sep 2018 07:26:13 -0700 (PDT)
Raw View
------=_Part_366_1791222983.1538144773718
Content-Type: multipart/alternative;
boundary="----=_Part_367_582198880.1538144773718"
------=_Part_367_582198880.1538144773718
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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 solution=
=20
would probably result in possible unnecessary comparisons (no logical short=
=20
circuiting) and additional storage for bool propagation (though I've not=20
looked at what the optimizer would do). Would prolly be better to=20
implement in the language to avoid those issues, even if it is only=20
syntactic sugar, as it can make the code more readable.
=20
>
>
> El jue., 27 de sep. de 2018 a la(s) 12:53, Addy (acl...@gmail.com=20
> <javascript:>) 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=
=20
>> 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 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/7b85d688-90=
13-407d-b7d3-10d28494e960%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-9=
013-407d-b7d3-10d28494e960%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/b917d650-33b0-459d-bba0-c0f03bc4db8d%40isocpp.or=
g.
------=_Part_367_582198880.1538144773718
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<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"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">I stepped into this too many times.<div>One of the issues are the =
four < vs <=3D combinations.</div><div><br></div><div>The way I solve=
d is by creating a temporal object that allows chain comparison, and a cast=
-to-bool operator.</div><div><br></div><div>if (chain(3) < x < 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) and addi=
tional storage for bool propagation (though I've not looked at what the=
optimizer would do).=C2=A0 Would prolly be better to implement in the lang=
uage to avoid those issues, even if it is only syntactic sugar, as it can m=
ake the code more readable.</div><div>=C2=A0</div><blockquote class=3D"gmai=
l_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, A=
ddy (<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Pdi=
dvbTJAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:'=
;;return true;" onclick=3D"this.href=3D'javascript:';return true;">=
acl...@gmail.com</a>) escribi=C3=B3:<br></div><blockquote class=3D"gmail_qu=
ote" 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 < x=
&& x < 100)</div><div><br></div><div>And would love a simple `s=
td::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" target=3D"_blank" rel=3D"n=
ofollow" onmousedown=3D"this.href=3D'https://www.google.com/url?q\x3dht=
tps%3A%2F%2Fgist.github.com%2Fmartinmoene%2F9410391\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A';return true;" onclick=3D=
"this.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github=
..com%2Fmartinmoene%2F9410391\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHAHmAn=
QG0jdVckwnN0Ql10D1V5-A';return true;">https://gist.github.com/<wbr>mart=
inmoene/9410391</a><br></div><div><br></div><div>templated<typename T, t=
ypename Compare></div><div>bool std::between(T lower, T upper, Compare c=
omp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lower) && 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" 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"=
PdidvbTJAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';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"PdidvbTJAAAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';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/7b85d688-9013-407d-b7d3-10d28494e960%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'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';return true;" on=
click=3D"this.href=3D'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';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's never wrong but always right?<br>Who'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" 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/b917d650-33b0-459d-bba0-c0f03bc4db8d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b917d650-33b0-459d-bba0-c0f03bc4db8d=
%40isocpp.org</a>.<br />
------=_Part_367_582198880.1538144773718--
------=_Part_366_1791222983.1538144773718--
.
Author: Daniel Gutson <danielgutson@gmail.com>
Date: Fri, 28 Sep 2018 11:31:43 -0300
Raw View
--0000000000003483390576ef5198
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
El vie., 28 sept. 2018 11:26, Jack Adrian Zappa <adrian.hawryluk@gmail.com>
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
>> 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 (no
> logical short circuiting)
>
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.
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, as 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/7b85d688-9=
013-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=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/b917d650-33b=
0-459d-bba0-c0f03bc4db8d%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b917d650-33=
b0-459d-bba0-c0f03bc4db8d%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
--=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-2%3D92DEL46jYrGPwESnUkwbYdrrWs%3DSfL3woc9=
A4H%2B6jQ%40mail.gmail.com.
--0000000000003483390576ef5198
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<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 <<a href=3D"mailto:adria=
n.hawryluk@gmail.com">adrian.hawryluk@gmail.com</a>> escribi=C3=B3:<br><=
/div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><br>On Friday, Sep=
tember 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 < vs <=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) < x < 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 dir=3D"auto"><br></div><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;padd=
ing-left:1ex"><div dir=3D"ltr"><div>and additional storage for bool propaga=
tion (though I've not looked at what the optimizer would do).=C2=A0 Wou=
ld prolly be better to implement in the language to avoid those issues, eve=
n if it is only syntactic sugar, as it can make the code more readable.</di=
v><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0;marg=
in-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 ju=
e., 27 de sep. de 2018 a la(s) 12:53, Addy (<a rel=3D"nofollow noreferrer">=
acl...@gmail.com</a>) escribi=C3=B3:<br></div><blockquote class=3D"gmail_qu=
ote" 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 < x=
&& x < 100)</div><div><br></div><div>And would love a simple `s=
td::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"nofollow noreferrer=
" target=3D"_blank">https://gist.github.com/martinmoene/9410391</a><br></di=
v><div><br></div><div>templated<typename T, typename Compare></div><d=
iv>bool std::between(T lower, T upper, Compare comp)</div><div>{</div><div>=
=C2=A0 =C2=A0 return comp(lower) && comp(upper);</div><div>}</div><=
div><br></div><div>Does anything like this exist? Should I propose it!?</di=
v></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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&utm_source=3Dfooter" rel=3D"nofollow no=
referrer" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/=
std-proposals/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.org</a>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
>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's never wrong but always right?<br>Who'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" 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/b917d650-33b0-459d-bba0-c0f03bc4db8d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"noreferrer">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/b917d650-33b0-459d-bba0-c0f03bc4db8d%40isocpp.org</a>.<br>
</blockquote></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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-2%3D92DEL46jYrGPwESnUkwbYdrrWs=
%3DSfL3woc9A4H%2B6jQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-2%3D=
92DEL46jYrGPwESnUkwbYdrrWs%3DSfL3woc9A4H%2B6jQ%40mail.gmail.com</a>.<br />
--0000000000003483390576ef5198--
.
Author: Adrian H <adrian.hawryluk@gmail.com>
Date: Fri, 28 Sep 2018 07:40:29 -0700 (PDT)
Raw View
------=_Part_382_1530680004.1538145629083
Content-Type: multipart/alternative;
boundary="----=_Part_383_935225925.1538145629083"
------=_Part_383_935225925.1538145629083
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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
> <javascript:>> 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 a=
s=20
> 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 you=
=20
dealt with short circuiting. Also, I take it that your solution wouldn't=
=20
allow comparisons of different types such as a double and a float, or would=
=20
it convert all objects to the type of first one chained?=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 th=
e=20
>> language to avoid those issues, even if it is only syntactic sugar, as i=
t=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 arguments=
=20
>>>> 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, 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/7b85d688-=
9013-407d-b7d3-10d28494e960%40isocpp.org=20
>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688=
-9013-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=3Demail&utm_source=3Df=
ooter>
>>>> .
>>>>
>>>
>>>
>>> --=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 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/b917d650-33=
b0-459d-bba0-c0f03bc4db8d%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b917d650-3=
3b0-459d-bba0-c0f03bc4db8d%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
--=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/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%40isocpp.or=
g.
------=_Part_383_935225925.1538145629083
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: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 <<a href=3D"javascript:" target=
=3D"_blank" gdf-obfuscated-mailto=3D"ZiSsNBfVAAAJ" rel=3D"nofollow" onmouse=
down=3D"this.href=3D'javascript:';return true;" onclick=3D"this.hre=
f=3D'javascript:';return true;">adrian....@gmail.com</a>> escrib=
i=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"><br><br>O=
n Friday, September 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I stepped into this too=
many times.<div>One of the issues are the four < vs <=3D combination=
s.</div><div><br></div><div>The way I solved is by creating a temporal obje=
ct that allows chain comparison, and a cast-to-bool operator.</div><div><br=
></div><div>if (chain(3) < x < 4)=C2=A0</div></div></blockquote><div>=
<br></div><div>So, something similar to the solution I provided?=C2=A0 As I=
said, that solution would probably result in possible unnecessary comparis=
ons (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 b=
oolean and the last right hand operand as its only state. It should do noth=
ing after the boolean becomes false.</div></div></blockquote><div><br></div=
><div>Could you provide your solution?=C2=A0 I'd be interested in findi=
ng out how you dealt with short circuiting.=C2=A0 Also, I take it that your=
solution wouldn't allow comparisons of different types such as a doubl=
e and a float, or would it convert all objects to the type of first one cha=
ined?=C2=A0</div><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 clas=
s=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've not looked at what=
the optimizer would do).=C2=A0 Would prolly be better to implement in the =
language to avoid those issues, even if it is only syntactic sugar, as it c=
an 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"><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, Ad=
dy (<a rel=3D"nofollow noreferrer">acl...@gmail.com</a>) escribi=C3=B3:<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">I do this pattern oft=
en:<div><br></div><div>if (0 < x && x < 100)</div><div><br></=
div><div>And would love a simple `std::between()` that would take two argum=
ents 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"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'=
;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fmartinmoen=
e%2F9410391\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D=
1V5-A';return true;" onclick=3D"this.href=3D'https://www.google.com=
/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fmartinmoene%2F9410391\x26sa\x3dD\=
x26sntz\x3d1\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A';return true;=
">https://gist.github.com/<wbr>martinmoene/9410391</a><br></div><div><br></=
div><div>templated<typename T, typename Compare></div><div>bool std::=
between(T lower, T upper, Compare comp)</div><div>{</div><div>=C2=A0 =C2=A0=
return comp(lower) && 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" 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&utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D'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';return true;" on=
click=3D"this.href=3D'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';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's never wrong but always right?<br>Who'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" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" rel=3D"nofollow" target=3D"_blank" gdf-obfu=
scated-mailto=3D"ZiSsNBfVAAAJ" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" rel=3D"nofollo=
w" target=3D"_blank" gdf-obfuscated-mailto=3D"ZiSsNBfVAAAJ" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';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/b917d650-33b0-459d-bba0-c0f03bc4db8d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D'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';return true;" on=
click=3D"this.href=3D'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';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" 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/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041=
%40isocpp.org</a>.<br />
------=_Part_383_935225925.1538145629083--
------=_Part_382_1530680004.1538145629083--
.
Author: Daniel Gutson <danielgutson@gmail.com>
Date: Fri, 28 Sep 2018 11:53:21 -0300
Raw View
--00000000000091b2870576ef9eac
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
El vie., 28 de sep. de 2018 a la(s) 11:40, Adrian H (
adrian.hawryluk@gmail.com) 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 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
>>>> 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 (no
>>> logical short circuiting)
>>>
>>
>> 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.
>>
>
> Could you provide your solution? I'd be interested in finding out how yo=
u
> 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 differen=
t
> types such as a double and a float, or would it convert all objects to th=
e
> 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 template argument
deduced. Let me provide the code later.
>
>
>> and additional storage for bool propagation (though I've not looked at
>>> what the optimizer would do). Would prolly be better to implement in t=
he
>>> language to avoid those issues, even if it is only syntactic sugar, as =
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 argument=
s
>>>>> 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, 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/7b85d688=
-9013-407d-b7d3-10d28494e960%40isocpp.org
>>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d68=
8-9013-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=3Demail&utm_source=3D=
footer>
>>>>> .
>>>>>
>>>>
>>>>
>>>> --
>>>> 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-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-3=
3b0-459d-bba0-c0f03bc4db8d%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b917d650-=
33b0-459d-bba0-c0f03bc4db8d%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>
>>> .
>>>
>> --
> 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/52d6bd1b-4af=
b-4f16-adde-8ee8b5ba1041%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/52d6bd1b-4a=
fb-4f16-adde-8ee8b5ba1041%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-3H6mrTgVNDe2ZGXmQ4WV9UQNv-EijJh%3DHnGHHHL=
7fh5w%40mail.gmail.com.
--00000000000091b2870576ef9eac
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) 11:40, 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:31:57 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"auto"><div><br><br><div class=3D"gmail_quote"><d=
iv dir=3D"ltr">El vie., 28 sept. 2018 11:26, Jack Adrian Zappa <<a rel=
=3D"nofollow">adrian....@gmail.com</a>> escribi=C3=B3:<br></div><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><br><br>On Friday, September 28, 20=
18 at 7:03:19 AM UTC-4, Daniel Gutson wrote:<blockquote class=3D"gmail_quot=
e" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr">I stepped into this too many times.<div>One of th=
e issues are the four < vs <=3D combinations.</div><div><br></div><di=
v>The way I solved is by creating a temporal object that allows chain compa=
rison, and a cast-to-bool operator.</div><div><br></div><div>if (chain(3) &=
lt; x < 4)=C2=A0</div></div></blockquote><div><br></div><div>So, somethi=
ng similar to the solution I provided?=C2=A0 As I said, that solution would=
probably result in possible unnecessary comparisons (no logical short circ=
uiting) </div></div></blockquote></div></div><div dir=3D"auto"><br></div><d=
iv 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 beco=
mes false.</div></div></blockquote><div><br></div><div>Could you provide yo=
ur solution?=C2=A0 I'd be interested in finding out how you dealt with =
short circuiting.=C2=A0 </div></div></blockquote><div><br></div><div>Sure, =
I'm in a conference but I will do later.</div><div>=C2=A0</div><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div>Also, I take it that your solu=
tion 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?=
=C2=A0</div></div></blockquote><div><br></div><div>Both the chain class and=
the comparison operators are templates. The result of the operator is a ne=
w (temporal) chain object with the template argument deduced. Let me provid=
e the code later.=C2=A0</div><div>=C2=A0</div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: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"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>and a=
dditional storage for bool propagation (though I've not looked at what =
the optimizer would do).=C2=A0 Would prolly be better to implement in the l=
anguage to avoid those issues, even if it is only syntactic sugar, as it ca=
n make the code more readable.</div><div>=C2=A0</div><blockquote class=3D"g=
mail_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"g=
mail_quote"><div dir=3D"ltr">El jue., 27 de sep. de 2018 a la(s) 12:53, Add=
y (<a rel=3D"nofollow noreferrer">acl...@gmail.com</a>) escribi=C3=B3:<br><=
/div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I do this pattern ofte=
n:<div><br></div><div>if (0 < x && x < 100)</div><div><br></d=
iv><div>And would love a simple `std::between()` that would take two argume=
nts 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/9=
410391" rel=3D"nofollow" target=3D"_blank">https://gist.github.com/martinmo=
ene/9410391</a><br></div><div><br></div><div>templated<typename T, typen=
ame Compare></div><div>bool std::between(T lower, T upper, Compare comp)=
</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lower) && comp(upp=
er);</div><div>}</div><div><br></div><div>Does anything like this exist? Sh=
ould 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" 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&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's never wrong but always right?<br>Who'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" 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&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" 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/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/52d6bd1b-4afb-=
4f16-adde-8ee8b5ba1041%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's never wrong but always right?<br>Who'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" 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-3H6mrTgVNDe2ZGXmQ4WV9UQNv-EijJ=
h%3DHnGHHHL7fh5w%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-3H6mrTgV=
NDe2ZGXmQ4WV9UQNv-EijJh%3DHnGHHHL7fh5w%40mail.gmail.com</a>.<br />
--00000000000091b2870576ef9eac--
.
Author: Adrian H <adrian.hawryluk@gmail.com>
Date: Fri, 28 Sep 2018 08:18:05 -0700 (PDT)
Raw View
------=_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'javascript:';return true;" onclick=3D"this.href=3D=
'javascript:';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 <<a rel=3D"nofollow">adrian....@gmail.com</a>> 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 < vs <=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) < x < 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'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'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'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 <iostrea=
m></font></div><div><font face=3D"monospace, monospace">#include <typ=
e_traits></font></div><div><font face=3D"monospace, monospace"><br></fon=
t></div><div><font face=3D"monospace, monospace">template<typename T>=
</font></div><div><font face=3D"monospace, monospace">struct chain_impl {</=
font></div><div><font face=3D"monospace, monospace">=C2=A0 chain_impl(T&=
;& obj, bool val) : obj(std::move(obj)), val(val) {}</font></div><div><=
font face=3D"monospace, monospace">=C2=A0 T&& 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<typename T></font></div><div><font face=3D"monospace, =
monospace">struct chain_impl<T&> {</font></div><div><font face=3D=
"monospace, monospace">=C2=A0 chain_impl(T& 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 <typename T></font></div><div=
><font face=3D"monospace, monospace">decltype(auto) make_chain(T&&=
=C2=A0 obj, bool val =3D true) {</font></div><div><font face=3D"monospace, =
monospace">=C2=A0 return chain_impl<std::conditional_t<<wbr>std::is_l=
value_reference<T>::<wbr>value, T&, T&&>>(std::forw=
ard<T>(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 <typename T0, typename=
T1></font></div><div><font face=3D"monospace, monospace">auto operator&=
lt; (chain_impl<T0>&& lhs, T1&& 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 < rhs);</font></div><div><font fa=
ce=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return make_chain(s=
td::forward<T1>(<wbr>rhs), lhs.val && 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<T1>(<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 << (make_chain(1) < 2 < 3=
? 1 : 0) << "\n";</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 << (make_c=
hain(a) < c < b ? 1 : 0) << "\n";</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'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 < x && x < 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'https://www.google.c=
om/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fmartinmoene%2F9410391\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A';return tru=
e;" onclick=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F=
%2Fgist.github.com%2Fmartinmoene%2F9410391\x26sa\x3dD\x26sntz\x3d1\x26usg\x=
3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A';return true;">https://gist.github=
..com/<wbr>martinmoene/9410391</a><br></div><div><br></div><div>templated<=
;typename T, typename Compare></div><div>bool std::between(T lower, T up=
per, Compare comp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lower) &=
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" 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&utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D'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';return true;" on=
click=3D"this.href=3D'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';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's never wrong but always right?<br>Who'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" 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&utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D'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';return true;" on=
click=3D"this.href=3D'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';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" 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'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';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'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';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&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'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';return true;" on=
click=3D"this.href=3D'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';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's never wrong but always right?<br>Who'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" 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--
.
Author: "Ivan G." <nekotekina@gmail.com>
Date: Fri, 28 Sep 2018 08:20:53 -0700 (PDT)
Raw View
------=_Part_390_487983814.1538148053301
Content-Type: multipart/alternative;
boundary="----=_Part_391_1147302689.1538148053301"
------=_Part_391_1147302689.1538148053301
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I'd like to see some kind of a range operator, for example, 100..200=20
returns special integral range type.
Then use some another operator to check whether a number is within this=20
range, for example:
if (x & -100..100)
{
}
=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D1=81=D0=B5=D0=BD=D1=82=D1=
=8F=D0=B1=D1=80=D1=8F 2018 =D0=B3., 19:07:24 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Jake Arkinstall=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> It has come up before. The issue is that a<b<c is evaluated as (a<b)<c,=
=20
> where (a<b) is a bool. We would thus need a special case to deal with thi=
s.
>
> Personally, I don't imagine that people are actually using a<b<c to=20
> compare the comparison (a<b) against c. Its possible, though, and so addi=
ng=20
> a special case for comparisons will break something somewhere. I want it,=
=20
> it's lovely syntax, but backwards compatibility is lovely too, even in=20
> cases where legacy code is doing something bizarre.
>
> On Thu, 27 Sep 2018, 16:53 Addy, <acl...@gmail.com <javascript:>> wrote:
>
>> I do this pattern often:
>>
>> if (0 < x && x < 100)
>>
>> And would love a simple `std::between()` that would take two arguments=
=20
>> 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 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/7b85d688-90=
13-407d-b7d3-10d28494e960%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7b85d688-9=
013-407d-b7d3-10d28494e960%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
--=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/add8451d-f375-49f3-a5cb-11dd6eb6f53f%40isocpp.or=
g.
------=_Part_391_1147302689.1538148053301
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I'd like to see some kind of a range operator, fo=
r example, 100..200 returns special integral range type.</div><div>Then use=
some another operator to check whether a number is within this range, for =
example:</div><div><div style=3D"background-color: #FAFAFA; border-color: #=
BBB; border-style: solid; border-width: 1px; word-wrap: break-word;" class=
=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<div style=3D"color: #000000;background-color: #ffffff;font-family: 'Dr=
oid Sans Mono', 'monospace', monospace, 'Droid Sans Fallbac=
k';font-weight: normal;font-size: 14px;line-height: 19px;white-space: p=
re;"><div><span style=3D"color: #000000;"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">=C2=A0 =C2=A0 </span></span><span style=3D"color: =
#af00db;"><span style=3D"color: #008;" class=3D"styled-by-prettify">if</spa=
n></span><span style=3D"color: #000000;"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">x </span></span><span style=3D"color: #000000;"><span style=3D"color:=
#660;" class=3D"styled-by-prettify">&</span></span><span style=3D"colo=
r: #000000;"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan></span><span style=3D"color: #000000;"><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">-</span></span><span style=3D"color: #09885a;"><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">100</span></span><s=
pan style=3D"color: #000000;"><span style=3D"color: #066;" class=3D"styled-=
by-prettify">.</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">.</span></span><span style=3D"color: #09885a;"><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">100</span></span><span style=3D"color: #0=
00000;"><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><=
/span></div><div><span style=3D"color: #000000;"><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span></span></div><div><span style=
=3D"color: #000000;"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> =C2=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">}</span></span></div></div><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br><br><br></span></div></code></div><br><br></div><div>=
<div><br></div></div><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D1=
=81=D0=B5=D0=BD=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2018 =D0=B3., 19:07:24 UTC+3 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Ja=
ke Arkinstall =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"auto">It has come up before. The is=
sue 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.<div dir=3D"auto"=
><br></div><div dir=3D"auto">Personally, I don't imagine that people ar=
e 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 bre=
ak something somewhere. I want it, it's lovely syntax, but backwards co=
mpatibility is lovely too, even in cases where legacy code is doing somethi=
ng bizarre.</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On T=
hu, 27 Sep 2018, 16:53 Addy, <<a href=3D"javascript:" target=3D"_blank" =
gdf-obfuscated-mailto=3D"-Po5HcYrGQAJ" rel=3D"nofollow" onmousedown=3D"this=
..href=3D'javascript:';return true;" onclick=3D"this.href=3D'jav=
ascript:';return true;">acl...@gmail.com</a>> wrote:<br></div><block=
quote 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 < x && x < 100)</div><div><br></div><div>And=
would love a simple `std::between()` that would take two arguments and an =
optional third (compare function) argument.</div><div><br></div><div>Simila=
r to this:=C2=A0<a href=3D"https://gist.github.com/martinmoene/9410391" rel=
=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'https://www=
..google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fmartinmoene%2F9410391\=
x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A';r=
eturn true;" onclick=3D"this.href=3D'https://www.google.com/url?q\x3dht=
tps%3A%2F%2Fgist.github.com%2Fmartinmoene%2F9410391\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHAHmAnQG0jdVckwnN0Ql10D1V5-A';return true;">https://gi=
st.github.com/martinmoene/9410391</a><br></div><div><br></div><div>template=
d<typename T, typename Compare></div><div>bool std::between(T lower, =
T upper, Compare comp)</div><div>{</div><div>=C2=A0 =C2=A0 return comp(lowe=
r) && comp(upper);</div><div>}</div><div><br></div><div>Does anythi=
ng like this exist? Should I propose it!?</div></div>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" rel=3D"nofollow" target=3D"_blank" gdf-obfu=
scated-mailto=3D"-Po5HcYrGQAJ" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" rel=3D"nofollo=
w" target=3D"_blank" gdf-obfuscated-mailto=3D"-Po5HcYrGQAJ" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';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/7b85d688-9013-407d-b7d3-10d28494e960%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D'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';return true;" on=
click=3D"this.href=3D'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';return true;">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/7b85d688-9013-407d-b7d3-10d28494e960%40=
isocpp.org</a>.<br>
</blockquote></div>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/add8451d-f375-49f3-a5cb-11dd6eb6f53f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/add8451d-f375-49f3-a5cb-11dd6eb6f53f=
%40isocpp.org</a>.<br />
------=_Part_391_1147302689.1538148053301--
------=_Part_390_487983814.1538148053301--
.
Author: Daniel Gutson <danielgutson@gmail.com>
Date: Fri, 28 Sep 2018 12:25:16 -0300
Raw View
--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 <<a rel=3D"nofollow">ad=
rian....@gmail.com</a>> 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 < vs <=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) < x < 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'd be interested in finding out how you dealt with short circuitin=
g.=C2=A0 </div></div></blockquote><div><br></div><div>Sure, I'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'=
;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 <iostream></font></div><d=
iv><font face=3D"monospace, monospace">#include <type_traits></font><=
/div><div><font face=3D"monospace, monospace"><br></font></div><div><font f=
ace=3D"monospace, monospace">template<typename T></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&& obj, bool val=
) : obj(std::move(obj)), val(val) {}</font></div><div><font face=3D"monospa=
ce, monospace">=C2=A0 T&& 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></font></div><div><font face=3D"monospace, monospace">struc=
t chain_impl<T&> {</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 chain_impl(T& obj, bool val) : obj(obj), val(val) {}</fon=
t></div><div><font face=3D"monospace, monospace">=C2=A0 T& 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 <typename T></font></div><div><font face=3D"m=
onospace, monospace">decltype(auto) make_chain(T&&=C2=A0 obj, bool =
val =3D true) {</font></div><div><font face=3D"monospace, monospace">=C2=A0=
return chain_impl<std::conditional_t<std::is_lvalue_reference<T&g=
t;::value, T&, T&&>>(std::forward<T>(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 <typename T0, typename T1></font></div><div><f=
ont face=3D"monospace, monospace">auto operator< (chain_impl<T0>&a=
mp;& lhs, T1&& 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'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 < rhs);</fo=
nt></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 return make_chain(std::forward<T1>(rhs), lhs.val && 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<T1>(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 << (make_chain(1) =
< 2 < 3 ? 1 : 0) << "\n";</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 <&l=
t; (make_chain(a) < c < b ? 1 : 0) << "\n";</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'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 < x && x < 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<typename T, typename Compare></=
div><div>bool std::between(T lower, T upper, Compare comp)</div><div>{</div=
><div>=C2=A0 =C2=A0 return comp(lower) && 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" 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&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's never wrong but always right?<br>Who'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" 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&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" 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&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's never wrong but always right?<br>Who'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" 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&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's never wrong but always right?<br>Who'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" 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--
.
Author: Adrian H <adrian.hawryluk@gmail.com>
Date: Fri, 28 Sep 2018 15:47:13 -0700 (PDT)
Raw View
------=_Part_581_1508307572.1538174833905
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
On Friday, September 28, 2018 at 11:25:30 AM UTC-4, Daniel Gutson wrote:
> El vie., 28 de sep. de 2018 a la(s) 12:18, Adrian H (adrian....@gmail.com=
) escribi=C3=B3:
>=20
> #include <iostream>
> #include <type_traits>
>=20
>=20
> template<typename T>
> struct chain_impl {
> =C2=A0 chain_impl(T&& obj, bool val) : obj(std::move(obj)), val(val) {}
> =C2=A0 T&& obj;
> =C2=A0 bool val;
> =C2=A0 explicit operator bool() {
> =C2=A0 =C2=A0 =C2=A0 return val;
> =C2=A0 }
> };
>=20
>=20
> template<typename T>
> struct chain_impl<T&> {
> =C2=A0 chain_impl(T& obj, bool val) : obj(obj), val(val) {}
> =C2=A0 T& obj;
> =C2=A0 bool val;
> =C2=A0 explicit operator bool() {
> =C2=A0 =C2=A0 =C2=A0 return val;
> =C2=A0 }
> };
>=20
>=20
> template <typename T>
> decltype(auto) make_chain(T&&=C2=A0 obj, bool val =3D true) {
> =C2=A0 return chain_impl<std::conditional_t<std::is_lvalue_reference<T>::=
value, T&, T&&>>(std::forward<T>(obj), val);
> }
>=20
>=20
> template <typename T0, typename T1>
> auto operator< (chain_impl<T0>&& lhs, T1&& rhs) {
> =C2=A0 =C2=A0 if (lhs.val) {
>=20
>=20
> Why you say that comparisons are performed? You are breaking the chain he=
re with this evaluation. So yes, operator will keep be called, but it's jus=
t this if.
So maybe not a comparison, but still a flag check for each comparison, rega=
rdless if it reached a potential short circuit point. Also, an extra Boolea=
n would be needed to be allocated for each term.
Unless you're saying that the optimizer will be able to detect this and sho=
rt circuit the operation and not allocate the Booleans? That would be nice,=
but I don't have that much faith in the optimizer. So unless it can optimi=
ze that code and data away then this feature would have to be on the compil=
er level so as not to add extra crap to the final binary.
> =C2=A0
>=20
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto result =3D make_chain(rhs, lhs.obj < rhs=
);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return make_chain(std::forward<T1>(rhs), lhs.=
val && result.val);
> =C2=A0 =C2=A0 }
> =C2=A0 =C2=A0 return make_chain(std::forward<T1>(rhs), false);
> }
>=20
>=20
> int main()
> {
> =C2=A0 std::cout << (make_chain(1) < 2 < 3 ? 1 : 0) << "\n";
> =C2=A0 int a=3D1, b=3D2, c=3D3;
>=20
> =C2=A0 std::cout << (make_chain(a) < c < b ? 1 : 0) << "\n";
> }
>=20
>=20
> Looking forward to seeing the difference.
Sorry. I don't understand your comment here.
>=20
> =C2=A0
>=20
>=20
>=20
>=20
>=20
>=20
>=20
>=20
>=20
> and additional storage for bool propagation (though I've not looked at wh=
at the optimizer would do).=C2=A0 Would prolly be better to implement in th=
e language to avoid those issues, even if it is only syntactic sugar, as it=
can make the code more readable.
> =C2=A0
>=20
>=20
>=20
>=20
>=20
> El jue., 27 de sep. de 2018 a la(s) 12:53, Addy (acl...@gmail.com) escrib=
i=C3=B3:
>=20
> I do this pattern often:
>=20
>=20
> if (0 < x && x < 100)
>=20
>=20
> And would love a simple `std::between()` that would take two arguments an=
d an optional third (compare function) argument.
>=20
>=20
> Similar to this:=C2=A0https://gist.github.com/martinmoene/9410391
>=20
>=20
>=20
> templated<typename T, typename Compare>
> bool std::between(T lower, T upper, Compare comp)
> {
> =C2=A0 =C2=A0 return comp(lower) && comp(upper);
> }
>=20
>=20
> Does anything like this exist? Should I propose it!?
>=20
>=20
>=20
>=20
> --=20
>=20
> You received this message because you are subscribed to the Google Groups=
"ISO C++ Standard - Future Proposals" group.
>=20
> To unsubscribe from this group and stop receiving emails from it, send an=
email to std-proposal...@isocpp.org.
>=20
> To post to this group, send email to std-pr...@isocpp.org.
>=20
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.=
org.
>=20
>=20
>=20
>=20
> --=20
>=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
>=20
>=20
>=20
>=20
> --=20
>=20
> You received this message because you are subscribed to the Google Groups=
"ISO C++ Standard - Future Proposals" group.
>=20
> To unsubscribe from this group and stop receiving emails from it, send an=
email to std-proposal...@isocpp.org.
>=20
> To post to this group, send email to std-pr...@isocpp.org.
>=20
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/b917d650-33b0-459d-bba0-c0f03bc4db8d%40isocpp.=
org.
>=20
>=20
>=20
>=20
>=20
>=20
>=20
> --=20
>=20
> You received this message because you are subscribed to the Google Groups=
"ISO C++ Standard - Future Proposals" group.
>=20
> To unsubscribe from this group and stop receiving emails from it, send an=
email to std-proposal...@isocpp.org.
>=20
> To post to this group, send email to std-pr...@isocpp.org.
>=20
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%40isocpp.=
org.
>=20
>=20
>=20
>=20
> --=20
>=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
>=20
>=20
>=20
>=20
> --=20
>=20
> You received this message because you are subscribed to the Google Groups=
"ISO C++ Standard - Future Proposals" group.
>=20
> To unsubscribe from this group and stop receiving emails from it, send an=
email to std-proposal...@isocpp.org.
>=20
> To post to this group, send email to std-pr...@isocpp.org.
>=20
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/bacc5cd9-230a-4865-858c-78566502cfef%40isocpp.=
org.
>=20
>=20
>=20
>=20
> --=20
>=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/952795b3-b87b-4140-b4f2-2c9ad968b2f7%40isocpp.or=
g.
------=_Part_581_1508307572.1538174833905--
.
Author: Adrian H <adrian.hawryluk@gmail.com>
Date: Tue, 2 Oct 2018 08:31:32 -0700 (PDT)
Raw View
------=_Part_282_985702005.1538494292518
Content-Type: multipart/alternative;
boundary="----=_Part_283_927077165.1538494292518"
------=_Part_283_927077165.1538494292518
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
On Friday, September 28, 2018 at 6:47:14 PM UTC-4, Adrian H wrote:
>
> On Friday, September 28, 2018 at 11:25:30 AM UTC-4, Daniel Gutson wrote:=
=20
> > El vie., 28 de sep. de 2018 a la(s) 12:18, Adrian H (
> adrian....@gmail.com) escribi=C3=B3:=20
> >=20
> > #include <iostream>=20
> > #include <type_traits>=20
> >=20
> >=20
> > template<typename T>=20
> > struct chain_impl {=20
> > chain_impl(T&& obj, bool val) : obj(std::move(obj)), val(val) {}=20
> > T&& obj;=20
> > bool val;=20
> > explicit operator bool() {=20
> > return val;=20
> > }=20
> > };=20
> >=20
> >=20
> > template<typename T>=20
> > struct chain_impl<T&> {=20
> > chain_impl(T& obj, bool val) : obj(obj), val(val) {}=20
> > T& obj;=20
> > bool val;=20
> > explicit operator bool() {=20
> > return val;=20
> > }=20
> > };=20
> >=20
> >=20
> > template <typename T>=20
> > decltype(auto) make_chain(T&& obj, bool val =3D true) {=20
> > return=20
> chain_impl<std::conditional_t<std::is_lvalue_reference<T>::value, T&,=20
> T&&>>(std::forward<T>(obj), val);=20
> > }=20
> >=20
> >=20
> > template <typename T0, typename T1>=20
> > auto operator< (chain_impl<T0>&& lhs, T1&& rhs) {=20
> > if (lhs.val) {=20
> >=20
> >=20
> > Why you say that comparisons are performed? You are breaking the chain=
=20
> here with this evaluation. So yes, operator will keep be called, but it's=
=20
> just this if.=20
>
> So maybe not a comparison, but still a flag check for each comparison,=20
> regardless if it reached a potential short circuit point. Also, an extra=
=20
> Boolean would be needed to be allocated for each term.=20
>
> Unless you're saying that the optimizer will be able to detect this and=
=20
> short circuit the operation and not allocate the Booleans? That would be=
=20
> nice, but I don't have that much faith in the optimizer. So unless it can=
=20
> optimize that code and data away then this feature would have to be on th=
e=20
> compiler level so as not to add extra crap to the final binary.=20
>
>
Wow. I take it back. The optimizer seems more than capable of removing=20
all of the cruft. gcc 8.2 output:
https://godbolt.org/z/DecqoQ
shows that there doesn't seem to be any boolean mid term storage and short=
=20
circuiting does appear to be happening. I'm really impressed.
Evan MS VC++ 2017 doesn't do too bad of a job. Though it does leave a=20
bunch of unnecessary code in the binary, it doesn't actually execute it. =
=20
https://godbolt.org/z/N58hN4
Truly impressive. Seems that there is really no need for this feature=20
after all.
A
--=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/6d2bdffd-187d-44e7-90b2-4c158ee19fe4%40isocpp.or=
g.
------=_Part_283_927077165.1538494292518
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, September 28, 2018 at 6:47:14 PM UTC-4, Adrian =
H wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Friday, September 2=
8, 2018 at 11:25:30 AM UTC-4, Daniel Gutson wrote:
<br>> El vie., 28 de sep. de 2018 a la(s) 12:18, Adrian H (<a>adrian....=
@gmail.com</a>) escribi=C3=B3:
<br>>=20
<br>> #include <iostream>
<br>> #include <type_traits>
<br>>=20
<br>>=20
<br>> template<typename T>
<br>> struct chain_impl {
<br>> =C2=A0 chain_impl(T&& obj, bool val) : obj(std::move(obj))=
, val(val) {}
<br>> =C2=A0 T&& obj;
<br>> =C2=A0 bool val;
<br>> =C2=A0 explicit operator bool() {
<br>> =C2=A0 =C2=A0 =C2=A0 return val;
<br>> =C2=A0 }
<br>> };
<br>>=20
<br>>=20
<br>> template<typename T>
<br>> struct chain_impl<T&> {
<br>> =C2=A0 chain_impl(T& obj, bool val) : obj(obj), val(val) {}
<br>> =C2=A0 T& obj;
<br>> =C2=A0 bool val;
<br>> =C2=A0 explicit operator bool() {
<br>> =C2=A0 =C2=A0 =C2=A0 return val;
<br>> =C2=A0 }
<br>> };
<br>>=20
<br>>=20
<br>> template <typename T>
<br>> decltype(auto) make_chain(T&&=C2=A0 obj, bool val =3D true=
) {
<br>> =C2=A0 return chain_impl<std::conditional_t<<wbr>std::is_lva=
lue_reference<T>::<wbr>value, T&, T&&>>(std::forwar=
d<T>(obj), val);
<br>> }
<br>>=20
<br>>=20
<br>> template <typename T0, typename T1>
<br>> auto operator< (chain_impl<T0>&& lhs, T1&&=
; rhs) {
<br>> =C2=A0 =C2=A0 if (lhs.val) {
<br>>=20
<br>>=20
<br>> Why you say that comparisons are performed? You are breaking the c=
hain here with this evaluation. So yes, operator will keep be called, but i=
t's just this if.
<br>
<br>So maybe not a comparison, but still a flag check for each comparison, =
regardless if it reached a potential short circuit point. Also, an extra Bo=
olean would be needed to be allocated for each term.
<br>
<br>Unless you're saying that the optimizer will be able to detect this=
and short circuit the operation and not allocate the Booleans? That would =
be nice, but I don't have that much faith in the optimizer. So unless i=
t can optimize that code and data away then this feature would have to be o=
n the compiler level so as not to add extra crap to the final binary.
<br>
<br></blockquote><div><br></div><div>Wow.=C2=A0 I take it back.=C2=A0 The o=
ptimizer seems more than capable of removing all of the cruft. gcc 8.2 outp=
ut:</div><div><br></div><div>https://godbolt.org/z/DecqoQ</div><div><br></d=
iv><div>shows that there doesn't seem to be any boolean mid term storag=
e and short circuiting does appear to be happening.=C2=A0 I'm really im=
pressed.</div><div><br></div><div>Evan MS VC++ 2017 doesn't do too bad =
of a job.=C2=A0 Though it does leave a bunch of unnecessary code in the bin=
ary, it doesn't actually execute it.=C2=A0 https://godbolt.org/z/N58hN4=
</div><div><br></div><div>Truly impressive.=C2=A0 Seems that there is reall=
y no need for this feature after all.</div><div><br></div><div><br></div><d=
iv>A</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/6d2bdffd-187d-44e7-90b2-4c158ee19fe4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6d2bdffd-187d-44e7-90b2-4c158ee19fe4=
%40isocpp.org</a>.<br />
------=_Part_283_927077165.1538494292518--
------=_Part_282_985702005.1538494292518--
.
Author: Adrian H <adrian.hawryluk@gmail.com>
Date: Tue, 2 Oct 2018 08:34:15 -0700 (PDT)
Raw View
------=_Part_1514_775975907.1538494455224
Content-Type: multipart/alternative;
boundary="----=_Part_1515_449969710.1538494455224"
------=_Part_1515_449969710.1538494455224
Content-Type: text/plain; charset="UTF-8"
On Tuesday, October 2, 2018 at 11:31:32 AM UTC-4, Adrian H wrote:
>
> Wow. I take it back. The optimizer seems more than capable of removing
> all of the cruft. gcc 8.2 output:
>
> https://godbolt.org/z/DecqoQ
>
> shows that there doesn't seem to be any boolean mid term storage and short
> circuiting does appear to be happening. I'm really impressed.
>
> Evan MS VC++ 2017 doesn't do too bad of a job. Though it does leave a
> bunch of unnecessary code in the binary, it doesn't actually execute it.
> https://godbolt.org/z/N58hN4
>
> Truly impressive. Seems that there is really no need for this feature
> after all.
>
Maybe something like this this should be added to the std lib then.
A
--
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/356e6b9d-b632-4274-896d-957935c576c1%40isocpp.org.
------=_Part_1515_449969710.1538494455224
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Tuesday, October 2, 2018 at 11:31:32 AM UTC-4, Adrian H=
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"><div>W=
ow.=C2=A0 I take it back.=C2=A0 The optimizer seems more than capable of re=
moving all of the cruft. gcc 8.2 output:</div><div><br></div><div><a href=
=3D"https://godbolt.org/z/DecqoQ" target=3D"_blank" rel=3D"nofollow" onmous=
edown=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fgod=
bolt.org%2Fz%2FDecqoQ\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFoL6qI6brxz0d=
MGMzJMb2fiE-l-w';return true;" onclick=3D"this.href=3D'https://www.=
google.com/url?q\x3dhttps%3A%2F%2Fgodbolt.org%2Fz%2FDecqoQ\x26sa\x3dD\x26sn=
tz\x3d1\x26usg\x3dAFQjCNFoL6qI6brxz0dMGMzJMb2fiE-l-w';return true;">htt=
ps://godbolt.org/z/DecqoQ</a></div><div><br></div><div>shows that there doe=
sn't seem to be any boolean mid term storage and short circuiting does =
appear to be happening.=C2=A0 I'm really impressed.</div><div><br></div=
><div>Evan MS VC++ 2017 doesn't do too bad of a job.=C2=A0 Though it do=
es leave a bunch of unnecessary code in the binary, it doesn't actually=
execute it.=C2=A0 <a href=3D"https://godbolt.org/z/N58hN4" target=3D"_blan=
k" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.com/=
url?q\x3dhttps%3A%2F%2Fgodbolt.org%2Fz%2FN58hN4\x26sa\x3dD\x26sntz\x3d1\x26=
usg\x3dAFQjCNH03vJbJf35gNtF2f50jVG4LHZRXw';return true;" onclick=3D"thi=
s.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fgodbolt.org%2Fz=
%2FN58hN4\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH03vJbJf35gNtF2f50jVG4LHZ=
RXw';return true;">https://godbolt.org/z/N58hN4</a></div><div><br></div=
><div>Truly impressive.=C2=A0 Seems that there is really no need for this f=
eature after all.</div></div></blockquote><div>=C2=A0</div>Maybe something =
like this this should be added to the std lib then.<br><br><div>A=C2=A0</di=
v></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/356e6b9d-b632-4274-896d-957935c576c1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/356e6b9d-b632-4274-896d-957935c576c1=
%40isocpp.org</a>.<br />
------=_Part_1515_449969710.1538494455224--
------=_Part_1514_775975907.1538494455224--
.