Topic: Adding std::is_between/in_range function


Author: Dan Raviv <dan.raviv@gmail.com>
Date: Wed, 15 Feb 2017 10:01:38 -0800 (PST)
Raw View
------=_Part_2528_1527062704.1487181698234
Content-Type: multipart/alternative;
 boundary="----=_Part_2529_2128541643.1487181698234"

------=_Part_2529_2128541643.1487181698234
Content-Type: text/plain; charset=UTF-8

It seems tempting to add an std::is_between/in_range function, which just
does

template<class T>
constexpr bool is_between( const T& v, const T& lo, const T& hi )
{
    return std::clamp(v, lo, hi) == v;
}

and obviously a similar version with a custom comparator.

This sort of function isn't available as far as I've seen. It think writing
if (is_between(v, lo, hi))
would be clearer, DRYer and less error-prone than either
if (std::clamp(v, lo, hi) == v)
or the usual
if (v >= lo && v <= hi)

Thoughts?

--
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/324fef50-3fc0-4b81-8b14-4ab021e659c9%40isocpp.org.

------=_Part_2529_2128541643.1487181698234
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>It seems tempting to add an std::is_between/in_range =
function, which just does<br></div><div><br></div><div><span class=3D"kw1" =
style=3D"line-height: 1.1em; color: rgb(0, 0, 221); font-family: DejaVuSans=
Mono, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.8000001=
90734863px; white-space: nowrap;">template</span><span class=3D"sy1" style=
=3D"line-height: 1.1em; color: rgb(0, 0, 128); font-family: DejaVuSansMono,=
 &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.800000190734=
863px; white-space: nowrap;">&lt;</span><span class=3D"kw1" style=3D"line-h=
eight: 1.1em; color: rgb(0, 0, 221); font-family: DejaVuSansMono, &#39;Deja=
Vu Sans Mono&#39;, courier, monospace; font-size: 12.800000190734863px; whi=
te-space: nowrap;">class</span><span style=3D"color: rgb(0, 0, 0); font-fam=
ily: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-s=
ize: 12.800000190734863px; white-space: nowrap;">=C2=A0T</span><span class=
=3D"sy1" style=3D"line-height: 1.1em; color: rgb(0, 0, 128); font-family: D=
ejaVuSansMono, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 1=
2.800000190734863px; white-space: nowrap;">&gt;</span><br style=3D"color: r=
gb(0, 0, 0); font-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, couri=
er, monospace; font-size: 12.800000190734863px; white-space: nowrap;"><span=
 class=3D"kw4" style=3D"line-height: 1.1em; color: rgb(0, 0, 255); font-fam=
ily: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-s=
ize: 12.800000190734863px; white-space: nowrap;">constexpr</span><span styl=
e=3D"color: rgb(0, 0, 0); font-family: DejaVuSansMono, &#39;DejaVu Sans Mon=
o&#39;, courier, monospace; font-size: 12.800000190734863px; white-space: n=
owrap;">=C2=A0</span><span style=3D"font-family: DejaVuSansMono, &#39;DejaV=
u Sans Mono&#39;, courier, monospace; font-size: 12.800000190734863px; whit=
e-space: nowrap;"><font color=3D"#0000ff">bool</font></span><span style=3D"=
color: rgb(0, 0, 0); font-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39=
;, courier, monospace; font-size: 12.800000190734863px; white-space: nowrap=
;">=C2=A0is_between</span><span class=3D"br0" style=3D"line-height: 1.1em; =
color: rgb(0, 128, 0); font-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#=
39;, courier, monospace; font-size: 12.800000190734863px; white-space: nowr=
ap;">(</span><span style=3D"color: rgb(0, 0, 0); font-family: DejaVuSansMon=
o, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.8000001907=
34863px; white-space: nowrap;">=C2=A0</span><span class=3D"kw4" style=3D"li=
ne-height: 1.1em; color: rgb(0, 0, 255); font-family: DejaVuSansMono, &#39;=
DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.800000190734863px;=
 white-space: nowrap;">const</span><span style=3D"color: rgb(0, 0, 0); font=
-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, courier, monospace; fo=
nt-size: 12.800000190734863px; white-space: nowrap;">=C2=A0T</span><span cl=
ass=3D"sy3" style=3D"line-height: 1.1em; color: rgb(0, 0, 64); font-family:=
 DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size:=
 12.800000190734863px; white-space: nowrap;">&amp;</span><span style=3D"col=
or: rgb(0, 0, 0); font-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, =
courier, monospace; font-size: 12.800000190734863px; white-space: nowrap;">=
=C2=A0v,=C2=A0</span><span class=3D"kw4" style=3D"line-height: 1.1em; color=
: rgb(0, 0, 255); font-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, =
courier, monospace; font-size: 12.800000190734863px; white-space: nowrap;">=
const</span><span style=3D"color: rgb(0, 0, 0); font-family: DejaVuSansMono=
, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.80000019073=
4863px; white-space: nowrap;">=C2=A0T</span><span class=3D"sy3" style=3D"li=
ne-height: 1.1em; color: rgb(0, 0, 64); font-family: DejaVuSansMono, &#39;D=
ejaVu Sans Mono&#39;, courier, monospace; font-size: 12.800000190734863px; =
white-space: nowrap;">&amp;</span><span style=3D"color: rgb(0, 0, 0); font-=
family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, courier, monospace; fon=
t-size: 12.800000190734863px; white-space: nowrap;">=C2=A0lo,=C2=A0</span><=
span class=3D"kw4" style=3D"line-height: 1.1em; color: rgb(0, 0, 255); font=
-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, courier, monospace; fo=
nt-size: 12.800000190734863px; white-space: nowrap;">const</span><span styl=
e=3D"color: rgb(0, 0, 0); font-family: DejaVuSansMono, &#39;DejaVu Sans Mon=
o&#39;, courier, monospace; font-size: 12.800000190734863px; white-space: n=
owrap;">=C2=A0T</span><span class=3D"sy3" style=3D"line-height: 1.1em; colo=
r: rgb(0, 0, 64); font-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, =
courier, monospace; font-size: 12.800000190734863px; white-space: nowrap;">=
&amp;</span><span style=3D"color: rgb(0, 0, 0); font-family: DejaVuSansMono=
, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.80000019073=
4863px; white-space: nowrap;">=C2=A0hi=C2=A0</span><span class=3D"br0" styl=
e=3D"line-height: 1.1em; color: rgb(0, 128, 0); font-family: DejaVuSansMono=
, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.80000019073=
4863px; white-space: nowrap;">)</span></div><div><font color=3D"#008080" fa=
ce=3D"DejaVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"=
font-size: 12.800000190734863px; white-space: nowrap;">{</span></font></div=
><div><font color=3D"#008080" face=3D"DejaVuSansMono, DejaVu Sans Mono, cou=
rier, monospace"><span style=3D"font-size: 12.800000190734863px; white-spac=
e: nowrap;">=C2=A0 =C2=A0 return std::clamp(v, lo, hi) =3D=3D v;</span></fo=
nt></div><div><font color=3D"#008080" face=3D"DejaVuSansMono, DejaVu Sans M=
ono, courier, monospace"><span style=3D"font-size: 12.800000190734863px; wh=
ite-space: nowrap;">}<br></span></font><div><br></div><div>and obviously a =
similar version with a custom comparator.</div><div><br></div><div>This sor=
t of function isn&#39;t available as far as I&#39;ve seen. It think writing=
</div><div><span style=3D"color: rgb(0, 128, 128); font-family: DejaVuSansM=
ono, &#39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.80000019=
0734863px; white-space: nowrap;">if (is_between(v, lo, hi))</span><br></div=
><div>would be clearer, DRYer and less error-prone than either</div></div><=
div><span style=3D"color: rgb(0, 128, 128); font-family: DejaVuSansMono, &#=
39;DejaVu Sans Mono&#39;, courier, monospace; font-size: 12.800000190734863=
px; white-space: nowrap;">if (std::clamp(v, lo, hi) =3D=3D v)</span><br></d=
iv><div>or the usual</div><div><span style=3D"color: rgb(0, 128, 128); font=
-family: DejaVuSansMono, &#39;DejaVu Sans Mono&#39;, courier, monospace; fo=
nt-size: 12.800000190734863px; white-space: nowrap;">if (v &gt;=3D lo &amp;=
&amp; v &lt;=3D hi)</span><br></div><div><br></div><div>Thoughts?</div></di=
v>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">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/324fef50-3fc0-4b81-8b14-4ab021e659c9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/324fef50-3fc0-4b81-8b14-4ab021e659c9=
%40isocpp.org</a>.<br />

------=_Part_2529_2128541643.1487181698234--

------=_Part_2528_1527062704.1487181698234--

.


Author: Barry Revzin <barry.revzin@gmail.com>
Date: Wed, 15 Feb 2017 10:51:52 -0800 (PST)
Raw View
------=_Part_10529_814117241.1487184712754
Content-Type: multipart/alternative;
 boundary="----=_Part_10530_1986288842.1487184712755"

------=_Part_10530_1986288842.1487184712755
Content-Type: text/plain; charset=UTF-8



On Wednesday, February 15, 2017 at 12:01:38 PM UTC-6, Dan Raviv wrote:
>
> It seems tempting to add an std::is_between/in_range function, which just
> does
>
> template<class T>
> constexpr bool is_between( const T& v, const T& lo, const T& hi )
> {
>     return std::clamp(v, lo, hi) == v;
> }
>
> and obviously a similar version with a custom comparator.
>
> This sort of function isn't available as far as I've seen. It think writing
> if (is_between(v, lo, hi))
> would be clearer, DRYer and less error-prone than either
> if (std::clamp(v, lo, hi) == v)
> or the usual
> if (v >= lo && v <= hi)
>
> Thoughts?
>

Herb's recent comparison paper (http://wg21.link/p0515) proposes properly
chaining comparisons, which would let you just write:

if (lo <= v <= hi)

That'd be the best solution, imo.

--
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/6597fe2a-a460-4c1e-8757-a28678f14eb3%40isocpp.org.

------=_Part_10530_1986288842.1487184712755
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, February 15, 2017 at 12:01:38 PM UTC=
-6, Dan Raviv wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div>It seems tempting to add an std::is_between/in_range function=
, which just does<br></div><div><br></div><div><span style=3D"line-height:1=
..1em;color:rgb(0,0,221);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#3=
9;,courier,monospace;font-size:12.800000190734863px;white-space:nowrap">tem=
plate</span><span style=3D"line-height:1.1em;color:rgb(0,0,128);font-family=
:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:12.8=
00000190734863px;white-space:nowrap">&lt;</span><span style=3D"line-height:=
1.1em;color:rgb(0,0,221);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#=
39;,courier,monospace;font-size:12.800000190734863px;white-space:nowrap">cl=
ass</span><span style=3D"color:rgb(0,0,0);font-family:DejaVuSansMono,&#39;D=
ejaVu Sans Mono&#39;,courier,monospace;font-size:12.800000190734863px;white=
-space:nowrap">=C2=A0T</span><span style=3D"line-height:1.1em;color:rgb(0,0=
,128);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monospa=
ce;font-size:12.800000190734863px;white-space:nowrap">&gt;</span><br style=
=3D"color:rgb(0,0,0);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,=
courier,monospace;font-size:12.800000190734863px;white-space:nowrap"><span =
style=3D"line-height:1.1em;color:rgb(0,0,255);font-family:DejaVuSansMono,&#=
39;DejaVu Sans Mono&#39;,courier,monospace;font-size:12.800000190734863px;w=
hite-space:nowrap">constexpr</span><span style=3D"color:rgb(0,0,0);font-fam=
ily:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:1=
2.800000190734863px;white-space:nowrap">=C2=A0</span><span style=3D"font-fa=
mily:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:=
12.800000190734863px;white-space:nowrap"><font color=3D"#0000ff">bool</font=
></span><span style=3D"color:rgb(0,0,0);font-family:DejaVuSansMono,&#39;Dej=
aVu Sans Mono&#39;,courier,monospace;font-size:12.800000190734863px;white-s=
pace:nowrap">=C2=A0is_between</span><span style=3D"line-height:1.1em;color:=
rgb(0,128,0);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,=
monospace;font-size:12.800000190734863px;white-space:nowrap">(</span><span =
style=3D"color:rgb(0,0,0);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&=
#39;,courier,monospace;font-size:12.800000190734863px;white-space:nowrap">=
=C2=A0</span><span style=3D"line-height:1.1em;color:rgb(0,0,255);font-famil=
y:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:12.=
800000190734863px;white-space:nowrap">con<wbr>st</span><span style=3D"color=
:rgb(0,0,0);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,m=
onospace;font-size:12.800000190734863px;white-space:nowrap">=C2=A0T</span><=
span style=3D"line-height:1.1em;color:rgb(0,0,64);font-family:DejaVuSansMon=
o,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:12.800000190734863=
px;white-space:nowrap">&amp;</span><span style=3D"color:rgb(0,0,0);font-fam=
ily:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:1=
2.800000190734863px;white-space:nowrap">=C2=A0v,=C2=A0</span><span style=3D=
"line-height:1.1em;color:rgb(0,0,255);font-family:DejaVuSansMono,&#39;DejaV=
u Sans Mono&#39;,courier,monospace;font-size:12.800000190734863px;white-spa=
ce:nowrap">const</span><span style=3D"color:rgb(0,0,0);font-family:DejaVuSa=
nsMono,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:12.8000001907=
34863px;white-space:nowrap">=C2=A0T</span><span style=3D"line-height:1.1em;=
color:rgb(0,0,64);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,cou=
rier,monospace;font-size:12.800000190734863px;white-space:nowrap">&amp;</sp=
an><span style=3D"color:rgb(0,0,0);font-family:DejaVuSansMono,&#39;DejaVu S=
ans Mono&#39;,courier,monospace;font-size:12.800000190734863px;white-space:=
nowrap">=C2=A0lo,=C2=A0</span><span style=3D"line-height:1.1em;color:rgb(0,=
0,255);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monosp=
ace;font-size:12.800000190734863px;white-space:nowrap">const</span><span st=
yle=3D"color:rgb(0,0,0);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#3=
9;,courier,monospace;font-size:12.800000190734863px;white-space:nowrap">=C2=
=A0T</span><span style=3D"line-height:1.1em;color:rgb(0,0,64);font-family:D=
ejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:12.800=
000190734863px;white-space:nowrap">&amp;</span><span style=3D"color:rgb(0,0=
,0);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,monospace=
;font-size:12.800000190734863px;white-space:nowrap"><wbr>=C2=A0hi=C2=A0</sp=
an><span style=3D"line-height:1.1em;color:rgb(0,128,0);font-family:DejaVuSa=
nsMono,&#39;DejaVu Sans Mono&#39;,courier,monospace;font-size:12.8000001907=
34863px;white-space:nowrap">)</span></div><div><font color=3D"#008080" face=
=3D"DejaVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"fo=
nt-size:12.800000190734863px;white-space:nowrap">{</span></font></div><div>=
<font color=3D"#008080" face=3D"DejaVuSansMono, DejaVu Sans Mono, courier, =
monospace"><span style=3D"font-size:12.800000190734863px;white-space:nowrap=
">=C2=A0 =C2=A0 return std::clamp(v, lo, hi) =3D=3D v;</span></font></div><=
div><font color=3D"#008080" face=3D"DejaVuSansMono, DejaVu Sans Mono, couri=
er, monospace"><span style=3D"font-size:12.800000190734863px;white-space:no=
wrap">}<br></span></font><div><br></div><div>and obviously a similar versio=
n with a custom comparator.</div><div><br></div><div>This sort of function =
isn&#39;t available as far as I&#39;ve seen. It think writing</div><div><sp=
an style=3D"color:rgb(0,128,128);font-family:DejaVuSansMono,&#39;DejaVu San=
s Mono&#39;,courier,monospace;font-size:12.800000190734863px;white-space:no=
wrap">if (is_between(v, lo, hi))</span><br></div><div>would be clearer, DRY=
er and less error-prone than either</div></div><div><span style=3D"color:rg=
b(0,128,128);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono&#39;,courier,=
monospace;font-size:12.800000190734863px;white-space:nowrap">if (std::clamp=
(v, lo, hi) =3D=3D v)</span><br></div><div>or the usual</div><div><span sty=
le=3D"color:rgb(0,128,128);font-family:DejaVuSansMono,&#39;DejaVu Sans Mono=
&#39;,courier,monospace;font-size:12.800000190734863px;white-space:nowrap">=
if (v &gt;=3D lo &amp;&amp; v &lt;=3D hi)</span><br></div><div><br></div><d=
iv>Thoughts?</div></div></blockquote><div><br></div><div>Herb&#39;s recent =
comparison paper (http://wg21.link/p0515) proposes properly chaining compar=
isons, which would let you just write:</div><div><br></div><div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><font=
 color=3D"#660066"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">if</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">lo </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;=3D</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> v </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&lt;=3D</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> hi</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span></font></div></code></div><br>That&#39;d be=
 the best solution, imo.<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">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/6597fe2a-a460-4c1e-8757-a28678f14eb3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6597fe2a-a460-4c1e-8757-a28678f14eb3=
%40isocpp.org</a>.<br />

------=_Part_10530_1986288842.1487184712755--

------=_Part_10529_814117241.1487184712754--

.


Author: gmisocpp@gmail.com
Date: Wed, 15 Feb 2017 11:49:09 -0800 (PST)
Raw View
------=_Part_10586_1451000826.1487188149569
Content-Type: multipart/alternative;
 boundary="----=_Part_10587_346678663.1487188149570"

------=_Part_10587_346678663.1487188149570
Content-Type: text/plain; charset=UTF-8


>
> Herb's recent comparison paper (http://wg21.link/p0515) proposes properly
> chaining comparisons, which would let you just write:
>
> if (lo <= v <= hi)
>
> That'd be the best solution, imo.
>

I personally despise that notation. I'd probably pattern match it and get
used to it, but I'd much rather is_between.
I also hate the if (10 <= a) instead of if (a <= 10) style so perhaps it's
just something quirky to me.
But is_between gets my vote all the same..

--
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/0104afdb-fdbd-4cfc-890a-ce6dae2dd73f%40isocpp.org.

------=_Part_10587_346678663.1487188149570
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; paddi=
ng-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px=
; border-left-style: solid;"><div dir=3D"ltr"><div>Herb&#39;s recent compar=
ison paper (<a onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\=
x3dhttp%3A%2F%2Fwg21.link%2Fp0515\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE=
BqUq4f6KMJ8z8gOISCYaQ3a5rWg&#39;;return true;" onclick=3D"this.href=3D&#39;=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fwg21.link%2Fp0515\x26sa\x3dD\x2=
6sntz\x3d1\x26usg\x3dAFQjCNEBqUq4f6KMJ8z8gOISCYaQ3a5rWg&#39;;return true;" =
href=3D"http://wg21.link/p0515" target=3D"_blank" rel=3D"nofollow">http://w=
g21.link/p0515</a>) proposes properly chaining comparisons, which would let=
 you just write:</div><div><br></div><div><div style=3D"border: 1px solid r=
gb(187, 187, 187); border-image: none; -ms-word-wrap: break-word; backgroun=
d-color: rgb(250, 250, 250);"><code><div><font color=3D"#660066"><span styl=
e=3D"color: rgb(0, 0, 136);">if</span><span style=3D"color: rgb(0, 0, 0);">=
 </span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"col=
or: rgb(0, 0, 0);">lo </span><span style=3D"color: rgb(102, 102, 0);">&lt;=
=3D</span><span style=3D"color: rgb(0, 0, 0);"> v </span><span style=3D"col=
or: rgb(102, 102, 0);">&lt;=3D</span><span style=3D"color: rgb(0, 0, 0);"> =
hi</span><span style=3D"color: rgb(102, 102, 0);">)</span></font></div></co=
de></div><br>That&#39;d be the best solution, imo.<br></div></div></blockqu=
ote><div><br></div><div>I personally despise that=C2=A0notation. I&#39;d pr=
obably pattern match it and get used to it, but I&#39;d much rather is_betw=
een.</div><div>I also hate the if (10 &lt;=3D a) instead of if (a &lt;=3D 1=
0) style so perhaps it&#39;s just=C2=A0something quirky=C2=A0to me.</div><d=
iv>But is_between gets my vote all the same..</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0104afdb-fdbd-4cfc-890a-ce6dae2dd73f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0104afdb-fdbd-4cfc-890a-ce6dae2dd73f=
%40isocpp.org</a>.<br />

------=_Part_10587_346678663.1487188149570--

------=_Part_10586_1451000826.1487188149569--

.


Author: "'Jeffrey Yasskin' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Wed, 15 Feb 2017 11:55:57 -0800
Raw View
is_sorted({lo, v, hi}) will probably work after the Ranges TS.

On Wed, Feb 15, 2017 at 10:01 AM, Dan Raviv <dan.raviv@gmail.com> wrote:
> It seems tempting to add an std::is_between/in_range function, which just
> does
>
> template<class T>
> constexpr bool is_between( const T& v, const T& lo, const T& hi )
> {
>     return std::clamp(v, lo, hi) == v;
> }
>
> and obviously a similar version with a custom comparator.
>
> This sort of function isn't available as far as I've seen. It think writing
> if (is_between(v, lo, hi))
> would be clearer, DRYer and less error-prone than either
> if (std::clamp(v, lo, hi) == v)
> or the usual
> if (v >= lo && v <= hi)
>
> Thoughts?
>
> --
> 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/324fef50-3fc0-4b81-8b14-4ab021e659c9%40isocpp.org.

--
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/CANh-dX%3D_sVmo9MwBFWpFCUrTnUYdkYGw0Wry_-NPRrw9664%3DGA%40mail.gmail.com.

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Wed, 15 Feb 2017 16:08:46 -0800 (PST)
Raw View
------=_Part_11092_788928891.1487203726658
Content-Type: multipart/alternative;
 boundary="----=_Part_11093_1115784999.1487203726658"

------=_Part_11093_1115784999.1487203726658
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Wednesday, February 15, 2017 at 11:49:09 AM UTC-8, gmis...@gmail.com=20
wrote:
>
> Herb's recent comparison paper (http://wg21.link/p0515) proposes properly=
=20
>> chaining comparisons, which would let you just write:
>>
>> if (lo <=3D v <=3D hi)
>>
>> That'd be the best solution, imo.
>>
>
> I personally despise that notation. I'd probably pattern match it and get=
=20
> used to it, but I'd much rather is_between.
> I also hate the if (10 <=3D a) instead of if (a <=3D 10) style so perhaps=
 it's=20
> just something quirky to me.
> But is_between gets my vote all the same..
>

I would never write the "Yoda notation" if (10 <=3D a), but for range tests=
 I=20
do invariably write

    if (lo <=3D v && v <=3D hi)

already. It doesn't bug me to have to write that extra "&& v"; my eyes and=
=20
fingers basically just ignore it.
Contrariwise, if I saw someone trying to introduce a function like the OP's=
=20
into my codebase, I'd strenuously object. Why would I take three things=20
that are intrinsically ordered =E2=80=94 lo, v, hi =E2=80=94 and deliberate=
ly write them in=20
the "wrong" order =E2=80=94 v, lo, hi? That just seems confusing.

Similarly, since std::clamp doesn't exist in any of my codebases yet, I'm=
=20
used to writing

    clamped_v =3D std::min(std::max(lo, v), hi);  // mnemonic: nouns in the=
=20
order {min max, lo v hi}

....even though I'm aware that in generic code these are currently=20
technically=20
<http://stackoverflow.com/questions/26584510/why-does-stdmax-return-the-wro=
ng-value>=20
better options due to a snafu in the definition of std::max:
std::min(std::max(v, lo), hi)  // mnemonic: nouns in the same order that=20
std::clamp wants them
std::max(std::min(v, hi), lo)

It would be nice to "fix" std::max, but maybe that's a non-starter because=
=20
of all the existing code that depends on its current behavior. I'm sure=20
it's been discussed ad nauseam.

=E2=80=93Arthur

--=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/bc38f107-e5a4-4132-b16f-041f37a71ea8%40isocpp.or=
g.

------=_Part_11093_1115784999.1487203726658
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, February 15, 2017 at 11:49:09 AM UTC-8, gmis=
....@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><blockquot=
e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;=
border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:=
solid"><div dir=3D"ltr"><div>Herb&#39;s recent comparison paper (<a href=3D=
"http://wg21.link/p0515" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"=
this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwg21.link%2Fp0=
515\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBqUq4f6KMJ8z8gOISCYaQ3a5rWg&#3=
9;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3=
dhttp%3A%2F%2Fwg21.link%2Fp0515\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBq=
Uq4f6KMJ8z8gOISCYaQ3a5rWg&#39;;return true;">http://wg21.link/p0515</a>) pr=
oposes properly chaining comparisons, which would let you just write:</div>=
<div><br></div><div><div style=3D"border:1px solid rgb(187,187,187);backgro=
und-color:rgb(250,250,250)"><code><div><font color=3D"#660066"><span style=
=3D"color:rgb(0,0,136)">if</span><span style=3D"color:rgb(0,0,0)"> </span><=
span style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)=
">lo </span><span style=3D"color:rgb(102,102,0)">&lt;=3D</span><span style=
=3D"color:rgb(0,0,0)"> v </span><span style=3D"color:rgb(102,102,0)">&lt;=
=3D</span><span style=3D"color:rgb(0,0,0)"> hi</span><span style=3D"color:r=
gb(102,102,0)">)</span></font></div></code></div><br>That&#39;d be the best=
 solution, imo.<br></div></div></blockquote><div><br></div><div>I personall=
y despise that=C2=A0notation. I&#39;d probably pattern match it and get use=
d to it, but I&#39;d much rather is_between.</div><div>I also hate the if (=
10 &lt;=3D a) instead of if (a &lt;=3D 10) style so perhaps it&#39;s just=
=C2=A0something quirky=C2=A0to me.</div><div>But is_between gets my vote al=
l the same..</div></blockquote><div><br></div><div>I would never write the =
&quot;Yoda notation&quot;=C2=A0<font face=3D"courier new, monospace">if (10=
 &lt;=3D a)</font>, but for range tests I do invariably write</div><div><br=
></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 if (lo &lt;=
=3D v &amp;&amp; v &lt;=3D hi)</font></div><div><br></div><div>already. It =
doesn&#39;t bug me to have to write that extra &quot;&amp;&amp; v&quot;; my=
 eyes and fingers basically just ignore it.</div><div>Contrariwise, if I sa=
w someone trying to introduce a function like the OP&#39;s into my codebase=
, I&#39;d strenuously object. Why would I take three things that are intrin=
sically ordered =E2=80=94 lo, v, hi =E2=80=94 and deliberately write them i=
n the &quot;wrong&quot; order =E2=80=94 v, lo, hi? That just seems confusin=
g.</div><div><br></div><div>Similarly, since std::clamp doesn&#39;t exist i=
n any of my codebases yet, I&#39;m used to writing</div><div><br></div><div=
><font face=3D"courier new, monospace">=C2=A0 =C2=A0 clamped_v =3D std::min=
(std::max(lo, v), hi); =C2=A0// mnemonic: nouns in the order {min max, lo v=
 hi}</font></div><div><br></div><div>...even though I&#39;m aware that in g=
eneric code these are <a href=3D"http://stackoverflow.com/questions/2658451=
0/why-does-stdmax-return-the-wrong-value">currently technically</a> better =
options due to a snafu in the definition of std::max:</div><div><font face=
=3D"courier new, monospace">std::min(std::max(v, lo), hi) =C2=A0// mnemonic=
: nouns in the same order that std::clamp wants them</font></div><div><div>=
<font face=3D"courier new, monospace">std::max(std::min(v, hi), lo)</font><=
/div></div><div><br></div><div>It would be nice to &quot;fix&quot; std::max=
, but maybe that&#39;s a non-starter because of all the existing code that =
depends on its current behavior. I&#39;m sure it&#39;s been discussed ad na=
useam.</div><div><br></div><div>=E2=80=93Arthur</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/bc38f107-e5a4-4132-b16f-041f37a71ea8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bc38f107-e5a4-4132-b16f-041f37a71ea8=
%40isocpp.org</a>.<br />

------=_Part_11093_1115784999.1487203726658--

------=_Part_11092_788928891.1487203726658--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 15 Feb 2017 19:47:27 -0500
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
 255, 255); line-height: initial;">                                        =
                                              <div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">If =E2=80=8Eyou think that we may ever get unified function cal=
ls, then it is best to put the 'object' of the function first.&nbsp;</div><=
div style=3D"width: 100%; font-size: initial; font-family: Calibri, 'Slate =
Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial;=
 background-color: rgb(255, 255, 255);"><br></div><div style=3D"width: 100%=
; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-s=
erif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(2=
55, 255, 255);">is_between(v, lo, hi)&nbsp;</div><div style=3D"width: 100%;=
 font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-se=
rif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(25=
5, 255, 255);">becomes</div><div style=3D"width: 100%; font-size: initial; =
font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 7=
3, 125); text-align: initial; background-color: rgb(255, 255, 255);">v.is_b=
etween(lo, hi)</div><div style=3D"width: 100%; font-size: initial; font-fam=
ily: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125);=
 text-align: initial; background-color: rgb(255, 255, 255);"><br></div><div=
 style=3D"width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro=
', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; ba=
ckground-color: rgb(255, 255, 255);">Even if you don't think unified functi=
ons ever will/should happen, it might still be a good rule for LEWG (and ot=
her library designers) to follow, just to increase consistency. </div><div =
style=3D"width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro'=
, sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; bac=
kground-color: rgb(255, 255, 255);"><br></div>                             =
                                                                           =
                             <div style=3D"width: 100%; font-size: initial;=
 font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, =
73, 125); text-align: initial; background-color: rgb(255, 255, 255);"><br><=
/div>                                                                      =
                                                                           =
                                                  <div style=3D"font-size: =
initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: =
rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255)=
;">Sent&nbsp;from&nbsp;my&nbsp;BlackBerry&nbsp;portable&nbsp;Babbage&nbsp;D=
evice</div>                                                                =
                                                                           =
                                       <table width=3D"100%" style=3D"backg=
round-color:white;border-spacing:0px;"> <tbody><tr><td colspan=3D"2" style=
=3D"font-size: initial; text-align: initial; background-color: rgb(255, 255=
, 255);">                           <div style=3D"border-style: solid none =
none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding:=
 3pt 0in 0in; font-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-size:=
 10pt;">  <div><b>From: </b>Arthur O'Dwyer</div><div><b>Sent: </b>Wednesday=
, February 15, 2017 7:08 PM</div><div><b>To: </b>ISO C++ Standard - Future =
Proposals</div><div><b>Reply To: </b>std-proposals@isocpp.org</div><div><b>=
Cc: </b>gmisocpp@gmail.com</div><div><b>Subject: </b>[std-proposals] Re: Ad=
ding std::is_between/in_range function</div></div></td></tr></tbody></table=
><div style=3D"border-style: solid none none; border-top-color: rgb(186, 18=
8, 209); border-top-width: 1pt; font-size: initial; text-align: initial; ba=
ckground-color: rgb(255, 255, 255);"></div><br><div id=3D"_originalContent"=
 style=3D""><div dir=3D"ltr">On Wednesday, February 15, 2017 at 11:49:09 AM=
 UTC-8, gmis...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;=
"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;paddi=
ng-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border=
-left-style:solid"><div dir=3D"ltr"><div>Herb's recent comparison paper (<a=
 href=3D"http://wg21.link/p0515" rel=3D"nofollow" target=3D"_blank" onmouse=
down=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwg21.link%=
2Fp0515\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBqUq4f6KMJ8z8gOISCYaQ3a5rW=
g';return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhtt=
p%3A%2F%2Fwg21.link%2Fp0515\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBqUq4f=
6KMJ8z8gOISCYaQ3a5rWg';return true;">http://wg21.link/p0515</a>) proposes p=
roperly chaining comparisons, which would let you just write:</div><div><br=
></div><div><div style=3D"border:1px solid rgb(187,187,187);background-colo=
r:rgb(250,250,250)"><code><div><font color=3D"#660066"><span style=3D"color=
:rgb(0,0,136)">if</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">lo </sp=
an><span style=3D"color:rgb(102,102,0)">&lt;=3D</span><span style=3D"color:=
rgb(0,0,0)"> v </span><span style=3D"color:rgb(102,102,0)">&lt;=3D</span><s=
pan style=3D"color:rgb(0,0,0)"> hi</span><span style=3D"color:rgb(102,102,0=
)">)</span></font></div></code></div><br>That'd be the best solution, imo.<=
br></div></div></blockquote><div><br></div><div>I personally despise that&n=
bsp;notation. I'd probably pattern match it and get used to it, but I'd muc=
h rather is_between.</div><div>I also hate the if (10 &lt;=3D a) instead of=
 if (a &lt;=3D 10) style so perhaps it's just&nbsp;something quirky&nbsp;to=
 me.</div><div>But is_between gets my vote all the same..</div></blockquote=
><div><br></div><div>I would never write the "Yoda notation"&nbsp;<font fac=
e=3D"courier new, monospace">if (10 &lt;=3D a)</font>, but for range tests =
I do invariably write</div><div><br></div><div><font face=3D"courier new, m=
onospace">&nbsp; &nbsp; if (lo &lt;=3D v &amp;&amp; v &lt;=3D hi)</font></d=
iv><div><br></div><div>already. It doesn't bug me to have to write that ext=
ra "&amp;&amp; v"; my eyes and fingers basically just ignore it.</div><div>=
Contrariwise, if I saw someone trying to introduce a function like the OP's=
 into my codebase, I'd strenuously object. Why would I take three things th=
at are intrinsically ordered =E2=80=94 lo, v, hi =E2=80=94 and deliberately=
 write them in the "wrong" order =E2=80=94 v, lo, hi? That just seems confu=
sing.</div><div><br></div><div>Similarly, since std::clamp doesn't exist in=
 any of my codebases yet, I'm used to writing</div><div><br></div><div><fon=
t face=3D"courier new, monospace">&nbsp; &nbsp; clamped_v =3D std::min(std:=
:max(lo, v), hi); &nbsp;// mnemonic: nouns in the order {min max, lo v hi}<=
/font></div><div><br></div><div>...even though I'm aware that in generic co=
de these are <a href=3D"http://stackoverflow.com/questions/26584510/why-doe=
s-stdmax-return-the-wrong-value">currently technically</a> better options d=
ue to a snafu in the definition of std::max:</div><div><font face=3D"courie=
r new, monospace">std::min(std::max(v, lo), hi) &nbsp;// mnemonic: nouns in=
 the same order that std::clamp wants them</font></div><div><div><font face=
=3D"courier new, monospace">std::max(std::min(v, hi), lo)</font></div></div=
><div><br></div><div>It would be nice to "fix" std::max, but maybe that's a=
 non-starter because of all the existing code that depends on its current b=
ehavior. I'm sure it's been discussed ad nauseam.</div><div><br></div><div>=
=E2=80=93Arthur</div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
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/bc38f107-e5a4-4132-b16f-041f37a71ea8%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/bc38f107-e5a4-4132-b16f-041f37a7=
1ea8%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div><br></body></html>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20170216004727.4902991.93934.24894%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20170216004727.4902991.93934.24894%40gm=
ail.com</a>.<br />

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 15 Feb 2017 18:24:03 -0800
Raw View
On quarta-feira, 15 de fevereiro de 2017 10:51:52 PST Barry Revzin wrote:
> if (lo <= v <= hi)
>
> That'd be the best solution, imo.

That will never work for non-primitive types, since operator< and operator<=
can be overloaded and return something other than bool.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

--
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/1563130.BmtcsS2rFA%40tjmaciei-mobl1.

.