Topic: How about a logical_self operator functor?


Author: ryan@imozo.cn
Date: Wed, 30 May 2018 12:33:41 -0700 (PDT)
Raw View
------=_Part_46146_757032927.1527708821884
Content-Type: multipart/alternative;
 boundary="----=_Part_46147_828597437.1527708821884"

------=_Part_46147_828597437.1527708821884
Content-Type: text/plain; charset="UTF-8"

For many times I have to write pass through unary operator for comparison
like:
[](bool b) { return b; }

It could be in using any_of, none_of or all_of with a container consisting
of Boolean values like testing conditions:

vector<bool> conditions;
....
return all_of(conditions.begin(), conditions.end(), [](bool b) { return b;
});

or in checking for non-zero's like:

vector<int> values;
....
return any_of(values.begin(), values.end(), [](int b) { return b; });

As we cannot and shall not use logical_negate<> twice and in order to
short-circuit the argument preparation and also to make the logical
operators complete, I propose we add a pass-through logical operator
functor to the function header.

--
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/ce34773b-7e3c-4d2c-933e-c0f3e1a982f9%40isocpp.org.

------=_Part_46147_828597437.1527708821884
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>For many times I have to write pass through unary ope=
rator for comparison like:</div><div><div class=3D"prettyprint" style=3D"bo=
rder: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color=
: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span class=3D"styled-by-prettify" style=3D"color: #660;">[](</span><=
span class=3D"styled-by-prettify" style=3D"color: #008;">bool</span><span c=
lass=3D"styled-by-prettify" style=3D"color: #000;"> b</span><span class=3D"=
styled-by-prettify" style=3D"color: #660;">)</span><span class=3D"styled-by=
-prettify" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify=
" style=3D"color: #660;">{</span><span class=3D"styled-by-prettify" style=
=3D"color: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color=
: #008;">return</span><span class=3D"styled-by-prettify" style=3D"color: #0=
00;"> b</span><span class=3D"styled-by-prettify" style=3D"color: #660;">;</=
span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><spa=
n class=3D"styled-by-prettify" style=3D"color: #660;">}</span><span class=
=3D"styled-by-prettify" style=3D"color: #000;"><br></span></div></code></di=
v><br></div><div>It could be in using any_of, none_of or all_of with a cont=
ainer consisting of Boolean values like testing conditions:</div><div><br><=
/div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 18=
7); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code cla=
ss=3D"prettyprint"><div class=3D"subprettyprint"><span class=3D"styled-by-p=
rettify" style=3D"color: #000;">vector</span><span class=3D"styled-by-prett=
ify" style=3D"color: #080;">&lt;bool&gt;</span><span class=3D"styled-by-pre=
ttify" style=3D"color: #000;"> conditions</span><span class=3D"styled-by-pr=
ettify" style=3D"color: #660;">;</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: #000;"><br></span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">...</span><span class=3D"styled-by-prettify" style=3D"col=
or: #000;"><br></span><span class=3D"styled-by-prettify" style=3D"color: #0=
08;">return</span><span class=3D"styled-by-prettify" style=3D"color: #000;"=
> all_of</span><span class=3D"styled-by-prettify" style=3D"color: #660;">(<=
/span><span class=3D"styled-by-prettify" style=3D"color: #000;">conditions<=
/span><span class=3D"styled-by-prettify" style=3D"color: #660;">.</span><sp=
an class=3D"styled-by-prettify" style=3D"color: #008;">begin</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: #660;">(),</span><span class=3D"=
styled-by-prettify" style=3D"color: #000;"> conditions</span><span class=3D=
"styled-by-prettify" style=3D"color: #660;">.</span><span class=3D"styled-b=
y-prettify" style=3D"color: #008;">end</span><span class=3D"styled-by-prett=
ify" style=3D"color: #660;">(),</span><span class=3D"styled-by-prettify" st=
yle=3D"color: #000;"> </span><span class=3D"styled-by-prettify" style=3D"co=
lor: #660;">[](</span><span class=3D"styled-by-prettify" style=3D"color: #0=
08;">bool</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> =
b</span><span class=3D"styled-by-prettify" style=3D"color: #660;">)</span><=
span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span clas=
s=3D"styled-by-prettify" style=3D"color: #660;">{</span><span class=3D"styl=
ed-by-prettify" style=3D"color: #000;"> </span><span class=3D"styled-by-pre=
ttify" style=3D"color: #008;">return</span><span class=3D"styled-by-prettif=
y" style=3D"color: #000;"> b</span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">;</span><span class=3D"styled-by-prettify" style=3D"color=
: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color: #660;">=
});</span><span class=3D"styled-by-prettify" style=3D"color: #000;"><br></s=
pan></div></code></div><br><div>or in checking for non-zero&#39;s like:</di=
v><div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px solid=
 rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250,=
 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span cla=
ss=3D"styled-by-prettify" style=3D"color: #000;">vector</span><span class=
=3D"styled-by-prettify" style=3D"color: #080;">&lt;int&gt;</span><span clas=
s=3D"styled-by-prettify" style=3D"color: #000;"> values</span><span class=
=3D"styled-by-prettify" style=3D"color: #660;">;</span><span class=3D"style=
d-by-prettify" style=3D"color: #000;"><br></span><span class=3D"styled-by-p=
rettify" style=3D"color: #660;">...</span><span class=3D"styled-by-prettify=
" style=3D"color: #000;"><br></span><span class=3D"styled-by-prettify" styl=
e=3D"color: #008;">return</span><span class=3D"styled-by-prettify" style=3D=
"color: #000;"> any_of</span><span class=3D"styled-by-prettify" style=3D"co=
lor: #660;">(</span><span class=3D"styled-by-prettify" style=3D"color: #000=
;">values</span><span class=3D"styled-by-prettify" style=3D"color: #660;">.=
</span><span class=3D"styled-by-prettify" style=3D"color: #008;">begin</spa=
n><span class=3D"styled-by-prettify" style=3D"color: #660;">(),</span><span=
 class=3D"styled-by-prettify" style=3D"color: #000;"> values</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: #660;">.</span><span class=3D"st=
yled-by-prettify" style=3D"color: #008;">end</span><span class=3D"styled-by=
-prettify" style=3D"color: #660;">(),</span><span class=3D"styled-by-pretti=
fy" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">[](</span><span class=3D"styled-by-prettify" style=3D"col=
or: #008;">int</span><span class=3D"styled-by-prettify" style=3D"color: #00=
0;"> b</span><span class=3D"styled-by-prettify" style=3D"color: #660;">)</s=
pan><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span=
 class=3D"styled-by-prettify" style=3D"color: #660;">{</span><span class=3D=
"styled-by-prettify" style=3D"color: #000;"> </span><span class=3D"styled-b=
y-prettify" style=3D"color: #008;">return</span><span class=3D"styled-by-pr=
ettify" style=3D"color: #000;"> b</span><span class=3D"styled-by-prettify" =
style=3D"color: #660;">;</span><span class=3D"styled-by-prettify" style=3D"=
color: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color: #6=
60;">});</span><span class=3D"styled-by-prettify" style=3D"color: #000;"><b=
r></span></div></code></div><br>As we cannot and shall not use logical_nega=
te&lt;&gt; twice and in order to short-circuit the argument preparation and=
 also to make the logical operators complete, I propose we add a pass-throu=
gh logical operator functor to the function header.</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/ce34773b-7e3c-4d2c-933e-c0f3e1a982f9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ce34773b-7e3c-4d2c-933e-c0f3e1a982f9=
%40isocpp.org</a>.<br />

------=_Part_46147_828597437.1527708821884--

------=_Part_46146_757032927.1527708821884--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 30 May 2018 20:42:18 +0100
Raw View
--000000000000aac12c056d718dfe
Content-Type: text/plain; charset="UTF-8"

So, to put it another way, you want something like std::as<T>

template <typename T>
struct as {
  template <typename U>
  T operator()(U&& x) { return static_cast<T>(x); }
};

in the language?

That way you could do

all_of(conditions.begin(), conditions.end(), std::as<bool>())

G

On Wed, May 30, 2018 at 8:33 PM, <ryan@imozo.cn> wrote:

> For many times I have to write pass through unary operator for comparison
> like:
> [](bool b) { return b; }
>
> It could be in using any_of, none_of or all_of with a container consisting
> of Boolean values like testing conditions:
>
> vector<bool> conditions;
> ...
> return all_of(conditions.begin(), conditions.end(), [](bool b) { return b;
> });
>
> or in checking for non-zero's like:
>
> vector<int> values;
> ...
> return any_of(values.begin(), values.end(), [](int b) { return b; });
>
> As we cannot and shall not use logical_negate<> twice and in order to
> short-circuit the argument preparation and also to make the logical
> operators complete, I propose we add a pass-through logical operator
> functor to the function header.
>
> --
> 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/ce34773b-7e3c-4d2c-
> 933e-c0f3e1a982f9%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ce34773b-7e3c-4d2c-933e-c0f3e1a982f9%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/CAANG%3DkU%3D_0FfcgFeh_jr7uzYpZ3-deGXS3TbDPnmCEnXXU%2BEAQ%40mail.gmail.com.

--000000000000aac12c056d718dfe
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">So, to put it another way, you want something like std::as=
&lt;T&gt;<div><br></div><div>template &lt;typename T&gt;</div><div>struct a=
s {</div><div>=C2=A0 template &lt;typename U&gt;</div><div>=C2=A0 T operato=
r()(U&amp;&amp; x) { return static_cast&lt;T&gt;(x); }<br></div><div>};</di=
v><div><br></div><div>in the language?</div><div><br></div><div>That way yo=
u could do</div><div><br></div><div>all_of(conditions.begin(), conditions.e=
nd(), std::as&lt;bool&gt;())</div><div><br></div><div>G</div></div><div cla=
ss=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, May 30, 2018 at 8=
:33 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:ryan@imozo.cn" target=3D"_=
blank">ryan@imozo.cn</a>&gt;</span> wrote:<br><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>For many times I have to write pass through unary o=
perator for comparison like:</div><div><div class=3D"m_348490290960883798pr=
ettyprint" style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;=
background-color:rgb(250,250,250)"><code class=3D"m_348490290960883798prett=
yprint"><div class=3D"m_348490290960883798subprettyprint"><span class=3D"m_=
348490290960883798styled-by-prettify" style=3D"color:#660">[](</span><span =
class=3D"m_348490290960883798styled-by-prettify" style=3D"color:#008">bool<=
/span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color=
:#000"> b</span><span class=3D"m_348490290960883798styled-by-prettify" styl=
e=3D"color:#660">)</span><span class=3D"m_348490290960883798styled-by-prett=
ify" style=3D"color:#000"> </span><span class=3D"m_348490290960883798styled=
-by-prettify" style=3D"color:#660">{</span><span class=3D"m_348490290960883=
798styled-by-prettify" style=3D"color:#000"> </span><span class=3D"m_348490=
290960883798styled-by-prettify" style=3D"color:#008">return</span><span cla=
ss=3D"m_348490290960883798styled-by-prettify" style=3D"color:#000"> b</span=
><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color:#660=
">;</span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"c=
olor:#000"> </span><span class=3D"m_348490290960883798styled-by-prettify" s=
tyle=3D"color:#660">}</span><span class=3D"m_348490290960883798styled-by-pr=
ettify" style=3D"color:#000"><br></span></div></code></div><br></div><div>I=
t could be in using any_of, none_of or all_of with a container consisting o=
f Boolean values like testing conditions:</div><div><br></div><div class=3D=
"m_348490290960883798prettyprint" style=3D"border:1px solid rgb(187,187,187=
);word-wrap:break-word;background-color:rgb(250,250,250)"><code class=3D"m_=
348490290960883798prettyprint"><div class=3D"m_348490290960883798subprettyp=
rint"><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color=
:#000">vector</span><span class=3D"m_348490290960883798styled-by-prettify" =
style=3D"color:#080">&lt;bool&gt;</span><span class=3D"m_348490290960883798=
styled-by-prettify" style=3D"color:#000"> conditions</span><span class=3D"m=
_348490290960883798styled-by-prettify" style=3D"color:#660">;</span><span c=
lass=3D"m_348490290960883798styled-by-prettify" style=3D"color:#000"><br></=
span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color:=
#660">...</span><span class=3D"m_348490290960883798styled-by-prettify" styl=
e=3D"color:#000"><br></span><span class=3D"m_348490290960883798styled-by-pr=
ettify" style=3D"color:#008">return</span><span class=3D"m_3484902909608837=
98styled-by-prettify" style=3D"color:#000"> all_of</span><span class=3D"m_3=
48490290960883798styled-by-prettify" style=3D"color:#660">(</span><span cla=
ss=3D"m_348490290960883798styled-by-prettify" style=3D"color:#000">conditio=
ns</span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"co=
lor:#660">.</span><span class=3D"m_348490290960883798styled-by-prettify" st=
yle=3D"color:#008">begin</span><span class=3D"m_348490290960883798styled-by=
-prettify" style=3D"color:#660">(),</span><span class=3D"m_3484902909608837=
98styled-by-prettify" style=3D"color:#000"> conditions</span><span class=3D=
"m_348490290960883798styled-by-prettify" style=3D"color:#660">.</span><span=
 class=3D"m_348490290960883798styled-by-prettify" style=3D"color:#008">end<=
/span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color=
:#660">(),</span><span class=3D"m_348490290960883798styled-by-prettify" sty=
le=3D"color:#000"> </span><span class=3D"m_348490290960883798styled-by-pret=
tify" style=3D"color:#660">[](</span><span class=3D"m_348490290960883798sty=
led-by-prettify" style=3D"color:#008">bool</span><span class=3D"m_348490290=
960883798styled-by-prettify" style=3D"color:#000"> b</span><span class=3D"m=
_348490290960883798styled-by-prettify" style=3D"color:#660">)</span><span c=
lass=3D"m_348490290960883798styled-by-prettify" style=3D"color:#000"> </spa=
n><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color:#66=
0">{</span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"=
color:#000"> </span><span class=3D"m_348490290960883798styled-by-prettify" =
style=3D"color:#008">return</span><span class=3D"m_348490290960883798styled=
-by-prettify" style=3D"color:#000"> b</span><span class=3D"m_34849029096088=
3798styled-by-prettify" style=3D"color:#660">;</span><span class=3D"m_34849=
0290960883798styled-by-prettify" style=3D"color:#000"> </span><span class=
=3D"m_348490290960883798styled-by-prettify" style=3D"color:#660">});</span>=
<span class=3D"m_348490290960883798styled-by-prettify" style=3D"color:#000"=
><br></span></div></code></div><br><div>or in checking for non-zero&#39;s l=
ike:</div><div><br></div><div><div class=3D"m_348490290960883798prettyprint=
" style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;backgroun=
d-color:rgb(250,250,250)"><code class=3D"m_348490290960883798prettyprint"><=
div class=3D"m_348490290960883798subprettyprint"><span class=3D"m_348490290=
960883798styled-by-prettify" style=3D"color:#000">vector</span><span class=
=3D"m_348490290960883798styled-by-prettify" style=3D"color:#080">&lt;int&gt=
;</span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"col=
or:#000"> values</span><span class=3D"m_348490290960883798styled-by-prettif=
y" style=3D"color:#660">;</span><span class=3D"m_348490290960883798styled-b=
y-prettify" style=3D"color:#000"><br></span><span class=3D"m_34849029096088=
3798styled-by-prettify" style=3D"color:#660">...</span><span class=3D"m_348=
490290960883798styled-by-prettify" style=3D"color:#000"><br></span><span cl=
ass=3D"m_348490290960883798styled-by-prettify" style=3D"color:#008">return<=
/span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color=
:#000"> any_of</span><span class=3D"m_348490290960883798styled-by-prettify"=
 style=3D"color:#660">(</span><span class=3D"m_348490290960883798styled-by-=
prettify" style=3D"color:#000">values</span><span class=3D"m_34849029096088=
3798styled-by-prettify" style=3D"color:#660">.</span><span class=3D"m_34849=
0290960883798styled-by-prettify" style=3D"color:#008">begin</span><span cla=
ss=3D"m_348490290960883798styled-by-prettify" style=3D"color:#660">(),</spa=
n><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color:#00=
0"> values</span><span class=3D"m_348490290960883798styled-by-prettify" sty=
le=3D"color:#660">.</span><span class=3D"m_348490290960883798styled-by-pret=
tify" style=3D"color:#008">end</span><span class=3D"m_348490290960883798sty=
led-by-prettify" style=3D"color:#660">(),</span><span class=3D"m_3484902909=
60883798styled-by-prettify" style=3D"color:#000"> </span><span class=3D"m_3=
48490290960883798styled-by-prettify" style=3D"color:#660">[](</span><span c=
lass=3D"m_348490290960883798styled-by-prettify" style=3D"color:#008">int</s=
pan><span class=3D"m_348490290960883798styled-by-prettify" style=3D"color:#=
000"> b</span><span class=3D"m_348490290960883798styled-by-prettify" style=
=3D"color:#660">)</span><span class=3D"m_348490290960883798styled-by-pretti=
fy" style=3D"color:#000"> </span><span class=3D"m_348490290960883798styled-=
by-prettify" style=3D"color:#660">{</span><span class=3D"m_3484902909608837=
98styled-by-prettify" style=3D"color:#000"> </span><span class=3D"m_3484902=
90960883798styled-by-prettify" style=3D"color:#008">return</span><span clas=
s=3D"m_348490290960883798styled-by-prettify" style=3D"color:#000"> b</span>=
<span class=3D"m_348490290960883798styled-by-prettify" style=3D"color:#660"=
>;</span><span class=3D"m_348490290960883798styled-by-prettify" style=3D"co=
lor:#000"> </span><span class=3D"m_348490290960883798styled-by-prettify" st=
yle=3D"color:#660">});</span><span class=3D"m_348490290960883798styled-by-p=
rettify" style=3D"color:#000"><br></span></div></code></div><br>As we canno=
t and shall not use logical_negate&lt;&gt; twice and in order to short-circ=
uit the argument preparation and also to make the logical operators complet=
e, I propose we add a pass-through logical operator functor to the function=
 header.</div></div><span class=3D"HOEnZb"><font color=3D"#888888">

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>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/ce34773b-7e3c-4d2c-933e-c0f3e1a982f9%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/ce34=
773b-7e3c-4d2c-<wbr>933e-c0f3e1a982f9%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></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/CAANG%3DkU%3D_0FfcgFeh_jr7uzYpZ3-deGX=
S3TbDPnmCEnXXU%2BEAQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkU%=
3D_0FfcgFeh_jr7uzYpZ3-deGXS3TbDPnmCEnXXU%2BEAQ%40mail.gmail.com</a>.<br />

--000000000000aac12c056d718dfe--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 30 May 2018 22:43:50 +0300
Raw View
On 30 May 2018 at 22:42, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.com> wr=
ote:
> So, to put it another way, you want something like std::as<T>
>
> template <typename T>
> struct as {
>   template <typename U>
>   T operator()(U&& x) { return static_cast<T>(x); }
> };
>
> in the language?
>
> That way you could do
>
> all_of(conditions.begin(), conditions.end(), std::as<bool>())

That thing is far more generic than a logical_self, for both good and bad.

--=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/CAFk2RUYkoFxLEiXV0Qb2v72u7Zed_%2BjPDkoN4FQbhmNpe=
wN2tQ%40mail.gmail.com.

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 30 May 2018 20:46:47 +0100
Raw View
--000000000000add4ad056d719df3
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I mean, I read that as "I want a lift of static_cast<bool> to a functor". A
lift of static_cast seems to be a useful thing to have, and it solves this
problem too :). IMO it's also easier to read.

Ga=C5=A1per

On Wed, May 30, 2018 at 8:43 PM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:

> On 30 May 2018 at 22:42, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.com> =
wrote:
> > So, to put it another way, you want something like std::as<T>
> >
> > template <typename T>
> > struct as {
> >   template <typename U>
> >   T operator()(U&& x) { return static_cast<T>(x); }
> > };
> >
> > in the language?
> >
> > That way you could do
> >
> > all_of(conditions.begin(), conditions.end(), std::as<bool>())
>
> That thing is far more generic than a logical_self, for both good and bad=
..
>
> --
> 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/CAFk2RUYkoFxLEiXV0Qb2v72u7Zed_
> %2BjPDkoN4FQbhmNpewN2tQ%40mail.gmail.com.
>

--=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/CAANG%3DkV0RziJFAAwaNG9qDMBjBDtRbMzkbmKrFdGHku6j=
a9fTQ%40mail.gmail.com.

--000000000000add4ad056d719df3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I mean, I read that as &quot;I want a lift of static_cast&=
lt;bool&gt; to a functor&quot;. A lift of static_cast seems to be a useful =
thing to have, and it solves this problem too :). IMO it&#39;s also easier =
to read.<div><br></div><div>Ga=C5=A1per</div></div><div class=3D"gmail_extr=
a"><br><div class=3D"gmail_quote">On Wed, May 30, 2018 at 8:43 PM, Ville Vo=
utilainen <span dir=3D"ltr">&lt;<a href=3D"mailto:ville.voutilainen@gmail.c=
om" target=3D"_blank">ville.voutilainen@gmail.com</a>&gt;</span> wrote:<br>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><span class=3D"">On 30 May 2018 at 22:42, Ga=
=C5=A1per A=C5=BEman &lt;<a href=3D"mailto:gasper.azman@gmail.com">gasper.a=
zman@gmail.com</a>&gt; wrote:<br>
&gt; So, to put it another way, you want something like std::as&lt;T&gt;<br=
>
&gt;<br>
&gt; template &lt;typename T&gt;<br>
&gt; struct as {<br>
&gt;=C2=A0 =C2=A0template &lt;typename U&gt;<br>
&gt;=C2=A0 =C2=A0T operator()(U&amp;&amp; x) { return static_cast&lt;T&gt;(=
x); }<br>
&gt; };<br>
&gt;<br>
&gt; in the language?<br>
&gt;<br>
&gt; That way you could do<br>
&gt;<br>
&gt; all_of(conditions.begin(), conditions.end(), std::as&lt;bool&gt;())<br=
>
<br>
</span>That thing is far more generic than a logical_self, for both good an=
d bad.<br>
<span class=3D""><br>
-- <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%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@<wbr>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>
</span>To view this discussion on the web visit <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYkoFxLEiXV0Qb2v72u7Zed_=
%2BjPDkoN4FQbhmNpewN2tQ%40mail.gmail.com" rel=3D"noreferrer" target=3D"_bla=
nk">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/=
<wbr>CAFk2RUYkoFxLEiXV0Qb2v72u7Zed_<wbr>%2BjPDkoN4FQbhmNpewN2tQ%<wbr>40mail=
..gmail.com</a>.<br>
</blockquote></div><br></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/CAANG%3DkV0RziJFAAwaNG9qDMBjBDtRbMzkb=
mKrFdGHku6ja9fTQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkV0RziJ=
FAAwaNG9qDMBjBDtRbMzkbmKrFdGHku6ja9fTQ%40mail.gmail.com</a>.<br />

--000000000000add4ad056d719df3--

.


Author: ryan@imozo.cn
Date: Wed, 30 May 2018 13:08:56 -0700 (PDT)
Raw View
------=_Part_45045_2014722353.1527710936694
Content-Type: multipart/alternative;
 boundary="----=_Part_45046_125864465.1527710936695"

------=_Part_45046_125864465.1527710936695
Content-Type: text/plain; charset="UTF-8"

Could do even better if we have also new overloads for any_of, none_of and
all_of that require no UnaryPredicate but instead use the element itself
for checking.

On Wednesday, May 30, 2018 at 3:33:41 PM UTC-4, ry...@imozo.cn wrote:
>
> For many times I have to write pass through unary operator for comparison
> like:
> [](bool b) { return b; }
>
> It could be in using any_of, none_of or all_of with a container consisting
> of Boolean values like testing conditions:
>
> vector<bool> conditions;
> ...
> return all_of(conditions.begin(), conditions.end(), [](bool b) { return b;
> });
>
> or in checking for non-zero's like:
>
> vector<int> values;
> ...
> return any_of(values.begin(), values.end(), [](int b) { return b; });
>
> As we cannot and shall not use logical_negate<> twice and in order to
> short-circuit the argument preparation and also to make the logical
> operators complete, I propose we add a pass-through logical operator
> functor to the function header.
>

--
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/c624e7b0-a864-4a92-9908-032ac74938bd%40isocpp.org.

------=_Part_45046_125864465.1527710936695
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Could do even better if we have also new overloads for any=
_of, none_of and all_of that require no <span style=3D"display: inline !imp=
ortant; float: none; background-color: transparent; color: rgb(0, 0, 0); fo=
nt-family: DejaVuSansMono,&quot;DejaVu Sans Mono&quot;,courier,monospace; f=
ont-size: 12.8px; font-size-adjust: none; font-stretch: 100%; font-style: n=
ormal; font-variant: normal; font-weight: 400; letter-spacing: normal; line=
-height: 15.36px; orphans: 2; text-align: left; text-decoration: none; text=
-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-s=
pace: pre; word-spacing: 0px;">UnaryPredicate </span>but instead use the el=
ement itself for checking.<br><br>On Wednesday, May 30, 2018 at 3:33:41 PM =
UTC-4, ry...@imozo.cn wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr"><div>For many times I have to write pass through unary opera=
tor for comparison like:</div><div><div style=3D"border:1px solid rgb(187,1=
87,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div>=
<span style=3D"color:#660">[](</span><span style=3D"color:#008">bool</span>=
<span style=3D"color:#000"> b</span><span style=3D"color:#660">)</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">return</span><span sty=
le=3D"color:#000"> b</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">}</span><span style=3D"c=
olor:#000"><br></span></div></code></div><br></div><div>It could be in usin=
g any_of, none_of or all_of with a container consisting of Boolean values l=
ike testing conditions:</div><div><br></div><div style=3D"border:1px solid =
rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><c=
ode><div><span style=3D"color:#000">vector</span><span style=3D"color:#080"=
>&lt;bool&gt;</span><span style=3D"color:#000"> conditions</span><span styl=
e=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#660">...</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">return</span><span style=3D"color:#000"> all_of</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000">conditions</span><=
span style=3D"color:#660">.</span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(),</span><span style=3D"color:#000"> conditions</=
span><span style=3D"color:#660">.</span><span style=3D"color:#008">end</spa=
n><span style=3D"color:#660">(),</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">[](</span><span style=3D"color:#008">bool</span><=
span style=3D"color:#000"> b</span><span style=3D"color:#660">)</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">return</span><span styl=
e=3D"color:#000"> b</span><span style=3D"color:#660">;</span><span style=3D=
"color:#000"> </span><span style=3D"color:#660">});</span><span style=3D"co=
lor:#000"><br></span></div></code></div><br><div>or in checking for non-zer=
o&#39;s like:</div><div><br></div><div><div style=3D"border:1px solid rgb(1=
87,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><=
div><span style=3D"color:#000">vector</span><span style=3D"color:#080">&lt;=
int&gt;</span><span style=3D"color:#000"> values</span><span style=3D"color=
:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"color:#=
660">...</span><span style=3D"color:#000"><br></span><span style=3D"color:#=
008">return</span><span style=3D"color:#000"> any_of</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">values</span><span style=3D"c=
olor:#660">.</span><span style=3D"color:#008">begin</span><span style=3D"co=
lor:#660">(),</span><span style=3D"color:#000"> values</span><span style=3D=
"color:#660">.</span><span style=3D"color:#008">end</span><span style=3D"co=
lor:#660">(),</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">[](</span><span style=3D"color:#008">int</span><span style=3D"color:=
#000"> b</span><span style=3D"color:#660">)</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">return</span><span style=3D"color:#000"> b<=
/span><span style=3D"color:#660">;</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">});</span><span style=3D"color:#000"><br></span=
></div></code></div><br>As we cannot and shall not use logical_negate&lt;&g=
t; twice and in order to short-circuit the argument preparation and also to=
 make the logical operators complete, I propose we add a pass-through logic=
al operator functor to the function header.</div></div></blockquote></div>

<p></p>

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

------=_Part_45046_125864465.1527710936695--

------=_Part_45045_2014722353.1527710936694--

.