Topic: Introducing standard unary predicates.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Mon, 8 Apr 2013 09:01:55 -0700 (PDT)
Raw View
------=_Part_898_29502345.1365436915964
Content-Type: text/plain; charset=ISO-8859-1

Standard functional objects are used very often to compare elements of a
sequence with zero. In these cases they are used together with binders as
for example function std::bind.
However It would made code simpler and easy to read if there will be
corresponding unary predicates in C++.

For example

template <class T> struct positive {
bool operator()(const T& x) const
{
return ( T( 0 ) < x );
}
typedef T argument_type;
typedef bool result_type;
};.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_898_29502345.1365436915964
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>Standard functional objects are used very often to compare&nbsp;elemen=
ts of a sequence with zero. In these cases they are used together with bind=
ers as for example function std::bind. </div><div>However It would made cod=
e simpler and easy to read if there will be corresponding unary predicates =
in C++.</div><div>&nbsp;</div><div>For example</div><div>&nbsp;</div><div>t=
emplate &lt;class T&gt; struct&nbsp;positive {<br>bool operator()(const T&a=
mp; x) const</div><div>{</div><div>return ( T( 0 ) &lt; x );</div><div>}<br=
>typedef T argument_type;</div><div>typedef bool result_type;<br>};.</div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_898_29502345.1365436915964--

.


Author: Jonathan Wakely <cxx@kayari.org>
Date: Tue, 9 Apr 2013 08:43:15 -0700 (PDT)
Raw View
------=_Part_2530_14988877.1365522195911
Content-Type: text/plain; charset=ISO-8859-1



On Monday, April 8, 2013 5:01:55 PM UTC+1, Vlad from Moscow wrote:
>
> Standard functional objects are used very often to compare elements of a
> sequence with zero. In these cases they are used together with binders as
> for example function std::bind.
> However It would made code simpler and easy to read if there will be
> corresponding unary predicates in C++.
>
> For example
>
> template <class T> struct positive {
> bool operator()(const T& x) const
> {
> return ( T( 0 ) < x );
> }
> typedef T argument_type;
> typedef bool result_type;
> };.
>

At the very least it should be consistent with the changes from
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm


--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_2530_14988877.1365522195911
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br>On Monday, April 8, 2013 5:01:55 PM UTC+1, Vlad from Moscow wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><div>Standard functional object=
s are used very often to compare&nbsp;elements of a sequence with zero. In =
these cases they are used together with binders as for example function std=
::bind. </div><div>However It would made code simpler and easy to read if t=
here will be corresponding unary predicates in C++.</div><div>&nbsp;</div><=
div>For example</div><div>&nbsp;</div><div>template &lt;class T&gt; struct&=
nbsp;positive {<br>bool operator()(const T&amp; x) const</div><div>{</div><=
div>return ( T( 0 ) &lt; x );</div><div>}<br>typedef T argument_type;</div>=
<div>typedef bool result_type;<br>};.</div></blockquote><div><br>At the ver=
y least it should be consistent with the changes from http://www.open-std.o=
rg/jtc1/sc22/wg21/docs/papers/2012/n3421.htm<br><br><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_2530_14988877.1365522195911--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 9 Apr 2013 10:41:43 -0700 (PDT)
Raw View
------=_Part_5513_31313037.1365529303551
Content-Type: text/plain; charset=ISO-8859-1


On Tuesday, April 9, 2013 7:43:15 PM UTC+4, Jonathan Wakely wrote:
>
>
>
> On Monday, April 8, 2013 5:01:55 PM UTC+1, Vlad from Moscow wrote:
>>
>> Standard functional objects are used very often to compare elements of a
>> sequence with zero. In these cases they are used together with binders as
>> for example function std::bind.
>> However It would made code simpler and easy to read if there will be
>> corresponding unary predicates in C++.
>>
>> For example
>>
>> template <class T> struct positive {
>> bool operator()(const T& x) const
>> {
>> return ( T( 0 ) < x );
>> }
>> typedef T argument_type;
>> typedef bool result_type;
>> };.
>>
>
> At the very least it should be consistent with the changes from
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm
>
>
>
Thanks, I read the proposal. But it seems that my proposal has no relation
with the given proposal. I want to introduce unary predicate that are used
very ofhen such as for example

std::negative, std::non_negative, std::positive, std::non_positive,
std::zeo (or std:;equal_to_zero), std::non_zero (or
std::not_equal_to_zero).

For example

auto n = std::count_if( std::begin(), std::end(), std::positive<int>() );

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_5513_31313037.1365529303551
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Tuesday, April 9, 2013 7:43:15 PM UTC+4, Jonathan Wakely wrote:<bloc=
kquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-c=
olor: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;=
" class=3D"gmail_quote"><br><br>On Monday, April 8, 2013 5:01:55 PM UTC+1, =
Vlad from Moscow wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padd=
ing-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1p=
x; border-left-style: solid;" class=3D"gmail_quote"><div>Standard functiona=
l objects are used very often to compare&nbsp;elements of a sequence with z=
ero. In these cases they are used together with binders as for example func=
tion std::bind. </div><div>However It would made code simpler and easy to r=
ead if there will be corresponding unary predicates in C++.</div><div>&nbsp=
;</div><div>For example</div><div>&nbsp;</div><div>template &lt;class T&gt;=
 struct&nbsp;positive {<br>bool operator()(const T&amp; x) const</div><div>=
{</div><div>return ( T( 0 ) &lt; x );</div><div>}<br>typedef T argument_typ=
e;</div><div>typedef bool result_type;<br>};.</div></blockquote><div><br>At=
 the very least it should be consistent with the changes from <a href=3D"ht=
tp://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm" target=3D"=
_blank">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2012/<wbr>n=
3421.htm</a><br><br><br></div></blockquote><div>&nbsp;</div><div>Thanks, I =
read the proposal. But it seems that my proposal has no&nbsp;relation with =
the&nbsp;given proposal. I want to introduce unary predicate&nbsp;that are =
used very&nbsp;ofhen such as for example</div><div>&nbsp;</div><div>std::ne=
gative, std::non_negative, std::positive, std::non_positive, std::zeo (or s=
td:;equal_to_zero), std::non_zero (or std::not_equal_to_zero).&nbsp;</div><=
div>&nbsp;</div><div>For example</div><div>&nbsp;</div><div>auto n =3D std:=
:count_if( std::begin(), std::end(), std::positive&lt;int&gt;() );</div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_5513_31313037.1365529303551--

.


Author: joel falcou <joel.falcou@gmail.com>
Date: Tue, 09 Apr 2013 19:45:40 +0200
Raw View
Le 09/04/2013 19:41, Vlad from Moscow a =E9crit :
> Thanks, I read the proposal. But it seems that my proposal has=20
> no relation with the given proposal. I want to introduce unary=20
> predicate that are used very ofhen such as for example
> std::negative, std::non_negative, std::positive, std::non_positive,=20
> std::zeo (or std:;equal_to_zero), std::non_zero (or=20
> std::not_equal_to_zero).
> For example
> auto n =3D std::count_if( std::begin(), std::end(), std::positive<int>() =
);
>

what's the benefit against using a simple lambda ?

--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/?hl=3Den.



.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Tue, 9 Apr 2013 12:48:13 -0500
Raw View
--f46d043c7f04b8737904d9f12ae7
Content-Type: text/plain; charset=ISO-8859-1

On 9 April 2013 12:41, Vlad from Moscow <vlad.moscow@mail.ru> wrote:

>
> Thanks, I read the proposal. But it seems that my proposal has no relation
> with the given proposal. I want to introduce unary predicate that are used
> very ofhen such as for example
>
> std::negative, std::non_negative, std::positive, std::non_positive,
> std::zeo (or std:;equal_to_zero), std::non_zero (or
> std::not_equal_to_zero).
>
> For example
>
> auto n = std::count_if( std::begin(), std::end(), std::positive<int>() );
>

I'm just not seeing why such a thing is common.  Given that it is just as
easy to write "[](int i){ return i > 0};" (and will be even better with
polymorphic lambdas), this doesn't seem worth the effort to add.
--
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--f46d043c7f04b8737904d9f12ae7
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 9 April 2013 12:41, Vlad from Moscow <span dir=3D"ltr">&lt;<a href=3D"ma=
ilto:vlad.moscow@mail.ru" target=3D"_blank">vlad.moscow@mail.ru</a>&gt;</sp=
an> wrote:<br><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><br>Thanks, I read the proposal. But it seems that my proposal has no=
=A0relation with the=A0given proposal. I want to introduce unary predicate=
=A0that are used very=A0ofhen such as for example</div><div>=A0</div><div>s=
td::negative, std::non_negative, std::positive, std::non_positive, std::zeo=
 (or std:;equal_to_zero), std::non_zero (or std::not_equal_to_zero).=A0</di=
v>

<div>=A0</div><div>For example</div><div>=A0</div><div>auto n =3D std::coun=
t_if( std::begin(), std::end(), std::positive&lt;int&gt;() );<br></div></bl=
ockquote><div><br>I&#39;m just not seeing why such a thing is common.=A0 Gi=
ven that it is just as easy to write &quot;[](int i){ return i &gt; 0};&quo=
t; (and will be even better with polymorphic lambdas), this doesn&#39;t see=
m worth the effort to add.<br>

</div></div>-- <br>=A0Nevin &quot;:-)&quot; Liber=A0 &lt;mailto:<a href=3D"=
mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>=
&gt;=A0 (847) 691-1404

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--f46d043c7f04b8737904d9f12ae7--

.


Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 9 Apr 2013 19:51:53 +0200
Raw View
2013/4/9 Vlad from Moscow <vlad.moscow@mail.ru>:
>
> On Tuesday, April 9, 2013 7:43:15 PM UTC+4, Jonathan Wakely wrote:
>>
>> On Monday, April 8, 2013 5:01:55 PM UTC+1, Vlad from Moscow wrote:
>>>
>>> Standard functional objects are used very often to compare elements of a
>>> sequence with zero. In these cases they are used together with binders as
>>> for example function std::bind.
>>> However It would made code simpler and easy to read if there will be
>>> corresponding unary predicates in C++.
>>>
>>> For example
>>>
>>> template <class T> struct positive {
>>> bool operator()(const T& x) const
>>> {
>>> return ( T( 0 ) < x );
>>> }
>>> typedef T argument_type;
>>> typedef bool result_type;
>>> };.
>>
>>
>> At the very least it should be consistent with the changes from
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm
>>
>>
>
> Thanks, I read the proposal. But it seems that my proposal has no relation
> with the given proposal.

It has. The idea of N3421 is to provide a specialization for the
function objects for T=void
that provide a generic perfect-forwarding function call operator.
Applied to your example
this would be (untested and only shortly thought about) something like:

template <> struct positive<void> {
  template<class T>
  auto operator()(T&& t) const -> -> decltype(std::declval<typename
decay<T>::type>(t) < std::forward<T>(t))
  {
    return typename decay<T>::type(0) < std::forward<T>(t);
  }
};

> I want to introduce unary predicate that are used
> very ofhen such as for example
>
> std::negative, std::non_negative, std::positive, std::non_positive, std::zeo
> (or std:;equal_to_zero), std::non_zero (or std::not_equal_to_zero).
>
> For example
>
> auto n = std::count_if( std::begin(), std::end(), std::positive<int>() );

Adapted to N3421 you could write that one as simpler:

auto n = std::count_if( std::begin(), std::end(), std::positive<>() );

- Daniel

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 9 Apr 2013 11:04:54 -0700 (PDT)
Raw View
------=_Part_324_32175125.1365530694269
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable


On Tuesday, April 9, 2013 9:45:40 PM UTC+4, Joel Falcou wrote:
>
> Le 09/04/2013 19:41, Vlad from Moscow a =EF=BF=BDcrit :=20
> > Thanks, I read the proposal. But it seems that my proposal has=20
> > no relation with the given proposal. I want to introduce unary=20
> > predicate that are used very ofhen such as for example=20
> > std::negative, std::non_negative, std::positive, std::non_positive,=20
> > std::zeo (or std:;equal_to_zero), std::non_zero (or=20
> > std::not_equal_to_zero).=20
> > For example=20
> > auto n =3D std::count_if( std::begin(), std::end(), std::positive<int>(=
)=20
> );=20
> >=20
>
> what's the benefit against using a simple lambda ?=20
>
> =20
Readability and adaptive turning. For example you can write
=20
 auto n =3D std::count_if( std::begin(), std::end(), std::not1(=20
std::positive<int>() ) );
=20
The same can be done with a lambda expression without packing it in=20
std::function.

--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/?hl=3Den.



------=_Part_324_32175125.1365530694269
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Tuesday, April 9, 2013 9:45:40 PM UTC+4, Joel Falcou wrote:<blockquo=
te 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;" cl=
ass=3D"gmail_quote">Le 09/04/2013 19:41, Vlad from Moscow a =EF=BF=BDcrit :
<br>&gt; Thanks, I read the proposal. But it seems that my proposal has=20
<br>&gt; no relation with the given proposal. I want to introduce unary=20
<br>&gt; predicate that are used very ofhen such as for example
<br>&gt; std::negative, std::non_negative, std::positive, std::non_positive=
,=20
<br>&gt; std::zeo (or std:;equal_to_zero), std::non_zero (or=20
<br>&gt; std::not_equal_to_zero).
<br>&gt; For example
<br>&gt; auto n =3D std::count_if( std::begin(), std::end(), std::positive&=
lt;int&gt;() );
<br>&gt;
<br>
<br>what's the benefit against using a simple lambda ?
<br>
<br></blockquote><div>&nbsp;</div><div>Readability and adaptive turning.&nb=
sp;For example you can write</div><div>&nbsp;</div><div>&nbsp;auto n =3D st=
d::count_if( std::begin(), std::end(), std::not1( std::positive&lt;int&gt;(=
) )&nbsp;);</div><div>&nbsp;</div><div>The same can be done with a lambda e=
xpression without packing it in std::function.<br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_324_32175125.1365530694269--

.


Author: joel falcou <joel.falcou@gmail.com>
Date: Tue, 09 Apr 2013 20:06:35 +0200
Raw View
What's not readable in :

auto c = count_if( x.begin(), x.end(), [](int e) { return e > 0; } );

or

auto c = count_if( x.begin(), x.end(), [](int e) { return e < 0; } );

?

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 9 Apr 2013 11:09:47 -0700 (PDT)
Raw View
------=_Part_433_17785930.1365530987693
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable


On Tuesday, April 9, 2013 9:51:53 PM UTC+4, Daniel Kr=FCgler wrote:
>
> 2013/4/9 Vlad from Moscow <vlad....@mail.ru <javascript:>>:=20
> >=20
> > On Tuesday, April 9, 2013 7:43:15 PM UTC+4, Jonathan Wakely wrote:=20
> >>=20
> >> On Monday, April 8, 2013 5:01:55 PM UTC+1, Vlad from Moscow wrote:=20
> >>>=20
> >>> Standard functional objects are used very often to compare elements o=
f=20
> a=20
> >>> sequence with zero. In these cases they are used together with binder=
s=20
> as=20
> >>> for example function std::bind.=20
> >>> However It would made code simpler and easy to read if there will be=
=20
> >>> corresponding unary predicates in C++.=20
> >>>=20
> >>> For example=20
> >>>=20
> >>> template <class T> struct positive {=20
> >>> bool operator()(const T& x) const=20
> >>> {=20
> >>> return ( T( 0 ) < x );=20
> >>> }=20
> >>> typedef T argument_type;=20
> >>> typedef bool result_type;=20
> >>> };.=20
> >>=20
> >>=20
> >> At the very least it should be consistent with the changes from=20
> >> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm=20
> >>=20
> >>=20
> >=20
> > Thanks, I read the proposal. But it seems that my proposal has no=20
> relation=20
> > with the given proposal.=20
>
> It has. The idea of N3421 is to provide a specialization for the=20
> function objects for T=3Dvoid=20
> that provide a generic perfect-forwarding function call operator.=20
> Applied to your example=20
> this would be (untested and only shortly thought about) something like:=
=20
>
> template <> struct positive<void> {=20
>   template<class T>=20
>   auto operator()(T&& t) const -> -> decltype(std::declval<typename=20
> decay<T>::type>(t) < std::forward<T>(t))=20
>   {=20
>     return typename decay<T>::type(0) < std::forward<T>(t);=20
>   }=20
> };=20
>
> > I want to introduce unary predicate that are used=20
> > very ofhen such as for example=20
> >=20
> > std::negative, std::non_negative, std::positive, std::non_positive,=20
> std::zeo=20
> > (or std:;equal_to_zero), std::non_zero (or std::not_equal_to_zero).=20
> >=20
> > For example=20
> >=20
> > auto n =3D std::count_if( std::begin(), std::end(), std::positive<int>(=
)=20
> );=20
>
> Adapted to N3421 you could write that one as simpler:=20
>
> auto n =3D std::count_if( std::begin(), std::end(), std::positive<>() );=
=20
>
> - Daniel=20
>
=20
=20
This is not so important as the idea itself to have special unary=20
predicates.:) Of course I will not protest against a more simple record of=
=20
the predicates but as it follows from the mentioned proposal two forms can=
=20
coexist.:)

--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/?hl=3Den.



------=_Part_433_17785930.1365530987693
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Tuesday, April 9, 2013 9:51:53 PM UTC+4, Daniel Kr=FCgler wrote:<blo=
ckquote 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=
;" class=3D"gmail_quote">2013/4/9 Vlad from Moscow &lt;<a href=3D"javascrip=
t:" target=3D"_blank" gdf-obfuscated-mailto=3D"h837TE51ayIJ">vlad....@mail.=
ru</a>&gt;:
<br>&gt;
<br>&gt; On Tuesday, April 9, 2013 7:43:15 PM UTC+4, Jonathan Wakely wrote:
<br>&gt;&gt;
<br>&gt;&gt; On Monday, April 8, 2013 5:01:55 PM UTC+1, Vlad from Moscow wr=
ote:
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; Standard functional objects are used very often to compare=
 elements of a
<br>&gt;&gt;&gt; sequence with zero. In these cases they are used together =
with binders as
<br>&gt;&gt;&gt; for example function std::bind.
<br>&gt;&gt;&gt; However It would made code simpler and easy to read if the=
re will be
<br>&gt;&gt;&gt; corresponding unary predicates in C++.
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; For example
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; template &lt;class T&gt; struct positive {
<br>&gt;&gt;&gt; bool operator()(const T&amp; x) const
<br>&gt;&gt;&gt; {
<br>&gt;&gt;&gt; return ( T( 0 ) &lt; x );
<br>&gt;&gt;&gt; }
<br>&gt;&gt;&gt; typedef T argument_type;
<br>&gt;&gt;&gt; typedef bool result_type;
<br>&gt;&gt;&gt; };.
<br>&gt;&gt;
<br>&gt;&gt;
<br>&gt;&gt; At the very least it should be consistent with the changes fro=
m
<br>&gt;&gt; <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/=
2012/n3421.htm" target=3D"_blank">http://www.open-std.org/jtc1/<wbr>sc22/wg=
21/docs/papers/2012/<wbr>n3421.htm</a>
<br>&gt;&gt;
<br>&gt;&gt;
<br>&gt;
<br>&gt; Thanks, I read the proposal. But it seems that my proposal has no =
relation
<br>&gt; with the given proposal.
<br>
<br>It has. The idea of N3421 is to provide a specialization for the
<br>function objects for T=3Dvoid
<br>that provide a generic perfect-forwarding function call operator.
<br>Applied to your example
<br>this would be (untested and only shortly thought about) something like:
<br>
<br>template &lt;&gt; struct positive&lt;void&gt; {
<br>&nbsp; template&lt;class T&gt;
<br>&nbsp; auto operator()(T&amp;&amp; t) const -&gt; -&gt; decltype(std::d=
eclval&lt;typename
<br>decay&lt;T&gt;::type&gt;(t) &lt; std::forward&lt;T&gt;(t))
<br>&nbsp; {
<br>&nbsp; &nbsp; return typename decay&lt;T&gt;::type(0) &lt; std::forward=
&lt;T&gt;(t);
<br>&nbsp; }
<br>};
<br>
<br>&gt; I want to introduce unary predicate that are used
<br>&gt; very ofhen such as for example
<br>&gt;
<br>&gt; std::negative, std::non_negative, std::positive, std::non_positive=
, std::zeo
<br>&gt; (or std:;equal_to_zero), std::non_zero (or std::not_equal_to_zero)=
..
<br>&gt;
<br>&gt; For example
<br>&gt;
<br>&gt; auto n =3D std::count_if( std::begin(), std::end(), std::positive&=
lt;int&gt;() );
<br>
<br>Adapted to N3421 you could write that one as simpler:
<br>
<br>auto n =3D std::count_if( std::begin(), std::end(), std::positive&lt;&g=
t;() );
<br>
<br>- Daniel
<br></blockquote><div>&nbsp;</div><div>&nbsp;</div><div>This is not so impo=
rtant as the idea itself to have special unary predicates.:)&nbsp;Of course=
 I will not protest&nbsp;against a&nbsp;more simple record of the predicate=
s but as it follows from the mentioned proposal two forms can coexist.:)</d=
iv>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_433_17785930.1365530987693--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 9 Apr 2013 11:11:49 -0700 (PDT)
Raw View
------=_Part_314_28982609.1365531109747
Content-Type: text/plain; charset=ISO-8859-1


On Tuesday, April 9, 2013 10:06:35 PM UTC+4, Joel Falcou wrote:
>
> What's not readable in :
>
> auto c = count_if( x.begin(), x.end(), [](int e) { return e > 0; } );
>
> or
>
> auto c = count_if( x.begin(), x.end(), [](int e) { return e < 0; } );
>
> ?
>
>

positive is the word that need no explanations. not1( positive ) is also
clear enough. Any lambda expression requirse some time to investigate 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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_314_28982609.1365531109747
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Tuesday, April 9, 2013 10:06:35 PM UTC+4, Joel Falcou wrote:<blockqu=
ote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-colo=
r: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" c=
lass=3D"gmail_quote">What's not readable in :
<br>
<br>auto c =3D count_if( x.begin(), x.end(), [](int e) { return e &gt; 0; }=
 );
<br>
<br>or
<br>
<br>auto c =3D count_if( x.begin(), x.end(), [](int e) { return e &lt; 0; }=
 );
<br>
<br>?
<br>
<br></blockquote><div>&nbsp;</div><div>&nbsp;</div><div>positive is the wor=
d that&nbsp;need no explanations. not1( positive ) is also clear enough. An=
y lambda expression requirse some time to investigate it.&nbsp;&nbsp;</div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_314_28982609.1365531109747--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 9 Apr 2013 11:17:27 -0700 (PDT)
Raw View
------=_Part_344_25013758.1365531447610
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable


On Tuesday, April 9, 2013 9:51:53 PM UTC+4, Daniel Kr=FCgler wrote:
>
> 2013/4/9 Vlad from Moscow <vlad....@mail.ru <javascript:>>:=20
> >=20
> > On Tuesday, April 9, 2013 7:43:15 PM UTC+4, Jonathan Wakely wrote:=20
> >>=20
> >> On Monday, April 8, 2013 5:01:55 PM UTC+1, Vlad from Moscow wrote:=20
> >>>=20
> >>> Standard functional objects are used very often to compare elements o=
f=20
> a=20
> >>> sequence with zero. In these cases they are used together with binder=
s=20
> as=20
> >>> for example function std::bind.=20
> >>> However It would made code simpler and easy to read if there will be=
=20
> >>> corresponding unary predicates in C++.=20
> >>>=20
> >>> For example=20
> >>>=20
> >>> template <class T> struct positive {=20
> >>> bool operator()(const T& x) const=20
> >>> {=20
> >>> return ( T( 0 ) < x );=20
> >>> }=20
> >>> typedef T argument_type;=20
> >>> typedef bool result_type;=20
> >>> };.=20
> >>=20
> >>=20
> >> At the very least it should be consistent with the changes from=20
> >> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm=20
> >>=20
> >>=20
> >=20
> > Thanks, I read the proposal. But it seems that my proposal has no=20
> relation=20
> > with the given proposal.=20
>
> It has. The idea of N3421 is to provide a specialization for the=20
> function objects for T=3Dvoid=20
> that provide a generic perfect-forwarding function call operator.=20
> Applied to your example=20
> this would be (untested and only shortly thought about) something like:=
=20
>
> template <> struct positive<void> {=20
>   template<class T>=20
>   auto operator()(T&& t) const -> -> decltype(std::declval<typename=20
> decay<T>::type>(t) < std::forward<T>(t))=20
>   {=20
>     return typename decay<T>::type(0) < std::forward<T>(t);=20
>   }=20
> };=20
>
> > I want to introduce unary predicate that are used=20
> > very ofhen such as for example=20
> >=20
> > std::negative, std::non_negative, std::positive, std::non_positive,=20
> std::zeo=20
> > (or std:;equal_to_zero), std::non_zero (or std::not_equal_to_zero).=20
> >=20
> > For example=20
> >=20
> > auto n =3D std::count_if( std::begin(), std::end(), std::positive<int>(=
)=20
> );=20
>
> Adapted to N3421 you could write that one as simpler:=20
>
> auto n =3D std::count_if( std::begin(), std::end(), std::positive<>() );=
=20
>
> - Daniel=20
>
=20
By the way looking at these two forms of the record of count_if I am not=20
sure that the second one is better than the first one. The first record=20
gives me  additional information about the value type of std::begin().=20
=20
auto n =3D std::count_if( std::begin(), std::end(), std::positive<int>() );

auto n =3D std::count_if( std::begin(), std::end(), std::positive<>() );

--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/?hl=3Den.



------=_Part_344_25013758.1365531447610
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Tuesday, April 9, 2013 9:51:53 PM UTC+4, Daniel Kr=FCgler wrote:<blo=
ckquote 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=
;" class=3D"gmail_quote">2013/4/9 Vlad from Moscow &lt;<a href=3D"javascrip=
t:" target=3D"_blank" gdf-obfuscated-mailto=3D"h837TE51ayIJ">vlad....@mail.=
ru</a>&gt;:
<br>&gt;
<br>&gt; On Tuesday, April 9, 2013 7:43:15 PM UTC+4, Jonathan Wakely wrote:
<br>&gt;&gt;
<br>&gt;&gt; On Monday, April 8, 2013 5:01:55 PM UTC+1, Vlad from Moscow wr=
ote:
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; Standard functional objects are used very often to compare=
 elements of a
<br>&gt;&gt;&gt; sequence with zero. In these cases they are used together =
with binders as
<br>&gt;&gt;&gt; for example function std::bind.
<br>&gt;&gt;&gt; However It would made code simpler and easy to read if the=
re will be
<br>&gt;&gt;&gt; corresponding unary predicates in C++.
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; For example
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; template &lt;class T&gt; struct positive {
<br>&gt;&gt;&gt; bool operator()(const T&amp; x) const
<br>&gt;&gt;&gt; {
<br>&gt;&gt;&gt; return ( T( 0 ) &lt; x );
<br>&gt;&gt;&gt; }
<br>&gt;&gt;&gt; typedef T argument_type;
<br>&gt;&gt;&gt; typedef bool result_type;
<br>&gt;&gt;&gt; };.
<br>&gt;&gt;
<br>&gt;&gt;
<br>&gt;&gt; At the very least it should be consistent with the changes fro=
m
<br>&gt;&gt; <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/=
2012/n3421.htm" target=3D"_blank">http://www.open-std.org/jtc1/<wbr>sc22/wg=
21/docs/papers/2012/<wbr>n3421.htm</a>
<br>&gt;&gt;
<br>&gt;&gt;
<br>&gt;
<br>&gt; Thanks, I read the proposal. But it seems that my proposal has no =
relation
<br>&gt; with the given proposal.
<br>
<br>It has. The idea of N3421 is to provide a specialization for the
<br>function objects for T=3Dvoid
<br>that provide a generic perfect-forwarding function call operator.
<br>Applied to your example
<br>this would be (untested and only shortly thought about) something like:
<br>
<br>template &lt;&gt; struct positive&lt;void&gt; {
<br>&nbsp; template&lt;class T&gt;
<br>&nbsp; auto operator()(T&amp;&amp; t) const -&gt; -&gt; decltype(std::d=
eclval&lt;typename
<br>decay&lt;T&gt;::type&gt;(t) &lt; std::forward&lt;T&gt;(t))
<br>&nbsp; {
<br>&nbsp; &nbsp; return typename decay&lt;T&gt;::type(0) &lt; std::forward=
&lt;T&gt;(t);
<br>&nbsp; }
<br>};
<br>
<br>&gt; I want to introduce unary predicate that are used
<br>&gt; very ofhen such as for example
<br>&gt;
<br>&gt; std::negative, std::non_negative, std::positive, std::non_positive=
, std::zeo
<br>&gt; (or std:;equal_to_zero), std::non_zero (or std::not_equal_to_zero)=
..
<br>&gt;
<br>&gt; For example
<br>&gt;
<br>&gt; auto n =3D std::count_if( std::begin(), std::end(), std::positive&=
lt;int&gt;() );
<br>
<br>Adapted to N3421 you could write that one as simpler:
<br>
<br>auto n =3D std::count_if( std::begin(), std::end(), std::positive&lt;&g=
t;() );
<br>
<br>- Daniel
<br></blockquote><div>&nbsp;</div><div>By the way looking at these two form=
s of the record of count_if I am not sure that the second one is better tha=
n the first one. The first record gives me&nbsp; additional information abo=
ut the value type of std::begin().&nbsp;</div><div>&nbsp;</div><div>auto n =
=3D std::count_if( std::begin(), std::end(), std::positive&lt;int&gt;() );<=
br><br>auto n =3D std::count_if( std::begin(), std::end(), std::positive&lt=
;&gt;() );<br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_344_25013758.1365531447610--

.