Topic: Changing descriptions of std::min_element,


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 12 Mar 2013 07:49:24 -0700 (PDT)
Raw View
------=_Part_1389_26657561.1363099764163
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

At present the description of for example std::min_element is the following

21 Returns: The *=EF=AC=81rst* iterator i in the range [first,last) such th=
at for=20
any iterator j in the range
[first,last) the following corresponding conditions hold: !(*j < *i) or=20
comp(*j, *i) =3D=3D false.
Returns last if first =3D=3D last.

However if to write=20

int a[] =3D { 1, 2, 2, 1 };

auto p =3D std::min_element( a, a + 4, std::less_equalj<int>() );

we will get a predictable result. p will be equal to a + 3. That is the=20
last minimum element will be found. However this behavior contradicts to=20
the description because neither std::less_equal<int>()( *a, *( a + 3 ) ) =
=3D=3D=20
false nor std::less_equal<int>()( *( a + 3 ), *a ) =3D=3D false.

In my opinion there is no any reason to exclude using predicate=20
std::less_equal (or similar) in such algorithms. Moreover it is the only=20
effective method to find the last minimum/maximum element in a sequence=20
that has forward iterator as for example std::forward_list.

So the current description is incorrect. I am suggesting to change it to=20
the following (for example for std::min_element)

21 Returns: Such iterator i in the range [first,last) that for any iterator=
=20
j in the range
[first,i) the following corresponding conditions hold: *i < *j or comp(*i,=
=20
*j) =3D=3D true; and for any iterator j in the range (i, end)  the followin=
g=20
corresponding conditions hold !(*j < *i) or comp(*j, *i) =3D=3D false.
Returns last if first =3D=3D last.

--=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_1389_26657561.1363099764163
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

At present the description of for example std::min_element is the following=
<div><br></div><div><div>21 Returns: The <b>=EF=AC=81rst</b> iterator i in =
the range [first,last) such that for any iterator j in the range</div><div>=
[first,last) the following corresponding conditions hold: !(*j &lt; *i) or =
comp(*j, *i) =3D=3D false.</div><div>Returns last if first =3D=3D last.</di=
v></div><div><br></div><div>However if to write&nbsp;</div><div><br></div><=
div>int a[] =3D { 1, 2, 2, 1 };</div><div><br></div><div>auto p =3D std::mi=
n_element( a, a + 4, std::less_equalj&lt;int&gt;() );</div><div><br></div><=
div>we will get a predictable result. p will be equal to a + 3. That is the=
 last minimum element will be found. However this behavior contradicts to t=
he description because neither std::less_equal&lt;int&gt;()( *a, *( a + 3 )=
 ) =3D=3D false nor std::less_equal&lt;int&gt;()( *( a + 3 ), *a ) =3D=3D f=
alse.</div><div><br></div><div>In my opinion there is no any reason to excl=
ude using predicate std::less_equal (or similar) in such algorithms. Moreov=
er it is the only effective method to find the last minimum/maximum element=
 in a sequence that has forward iterator as for example std::forward_list.<=
/div><div><br></div><div>So the current description is incorrect. I am sugg=
esting to change it to the following (for example for std::min_element)<br>=
</div><div><br></div><div><div>21 Returns: Such&nbsp;iterator i in the rang=
e [first,last) that for any iterator j in the range</div><div>[first,i) the=
 following corresponding conditions hold: *i &lt; *j or comp(*i, *j) =3D=3D=
 true; and for any iterator j in the range (i, end) &nbsp;the following cor=
responding conditions hold !(*j &lt; *i) or comp(*j, *i) =3D=3D false.</div=
><div>Returns last if first =3D=3D last.</div></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_1389_26657561.1363099764163--

.


Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 12 Mar 2013 16:23:54 +0100
Raw View
2013/3/12 Vlad from Moscow <vlad.moscow@mail.ru>:
> At present the description of for example std::min_element is the followi=
ng
>
> 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) such th=
at for any
> iterator j in the range
> [first,last) the following corresponding conditions hold: !(*j < *i) or
> comp(*j, *i) =3D=3D false.
> Returns last if first =3D=3D last.
>
> However if to write
>
> int a[] =3D { 1, 2, 2, 1 };
>
> auto p =3D std::min_element( a, a + 4, std::less_equalj<int>() );

(I assume, you mean std::less_equal) This code has undefined
behaviour, because it violates a general pre-condition described in
[alg.sorting] p3 that the template parameter named "Compare" shall
induce a strict weak ordering. std::less_equal<int> doesn't satisfy
this, because it is a reflexive relation.

- Daniel

--=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: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 13 Mar 2013 04:04:14 -0700 (PDT)
Raw View
------=_Part_973_20341651.1363172654252
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


On Tuesday, March 12, 2013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wrote:
>
> 2013/3/12 Vlad from Moscow <vlad....@mail.ru <javascript:>>:=20
> > At present the description of for example std::min_element is the=20
> following=20
> >=20
> > 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) such =
that for=20
> any=20
> > iterator j in the range=20
> > [first,last) the following corresponding conditions hold: !(*j < *i) or=
=20
> > comp(*j, *i) =3D=3D false.=20
> > Returns last if first =3D=3D last.=20
> >=20
> > However if to write=20
> >=20
> > int a[] =3D { 1, 2, 2, 1 };=20
> >=20
> > auto p =3D std::min_element( a, a + 4, std::less_equalj<int>() );=20
>
> (I assume, you mean std::less_equal) This code has undefined=20
> behaviour, because it violates a general pre-condition described in=20
> [alg.sorting] p3 that the template parameter named "Compare" shall=20
> induce a strict weak ordering. std::less_equal<int> doesn't satisfy=20
> this, because it is a reflexive relation.=20
>
> - Daniel=20
>
=20
I wanted to say that there is no any need to specify the strict weak=20
ordering for these algorithms. Any binary predicate can be used. So instead=
=20
of undefined behavior that looks very silly we will get the last minimum or=
=20
maximum. It is the only effective method to get the last extremum for=20
sequences that have a forward iterator.=20

--=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_973_20341651.1363172654252
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br>On Tuesday, March 12, 2013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wrote:=
<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-l=
eft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: s=
olid;" class=3D"gmail_quote">2013/3/12 Vlad from Moscow &lt;<a href=3D"java=
script:" target=3D"_blank" gdf-obfuscated-mailto=3D"kIQn8V20uYoJ">vlad....@=
mail.ru</a>&gt;:
<br>&gt; At present the description of for example std::min_element is the =
following
<br>&gt;
<br>&gt; 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) =
such that for any
<br>&gt; iterator j in the range
<br>&gt; [first,last) the following corresponding conditions hold: !(*j &lt=
; *i) or
<br>&gt; comp(*j, *i) =3D=3D false.
<br>&gt; Returns last if first =3D=3D last.
<br>&gt;
<br>&gt; However if to write
<br>&gt;
<br>&gt; int a[] =3D { 1, 2, 2, 1 };
<br>&gt;
<br>&gt; auto p =3D std::min_element( a, a + 4, std::less_equalj&lt;int&gt;=
() );
<br>
<br>(I assume, you mean std::less_equal) This code has undefined
<br>behaviour, because it violates a general pre-condition described in
<br>[alg.sorting] p3 that the template parameter named "Compare" shall
<br>induce a strict weak ordering. std::less_equal&lt;int&gt; doesn't satis=
fy
<br>this, because it is a reflexive relation.
<br>
<br>- Daniel
<br></blockquote><div>&nbsp;</div><div>I wanted to say that there is no any=
 need to specify the strict weak ordering for these algorithms. Any&nbsp;bi=
nary predicate can be used. So instead of undefined behavior that looks ver=
y silly we will get the last minimum&nbsp;or maximum. It is the only effect=
ive method to get the last extremum for sequences that have a forward itera=
tor.&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_973_20341651.1363172654252--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 13 Mar 2013 05:32:06 -0700 (PDT)
Raw View
------=_Part_316_21563909.1363177926053
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Wednesday, March 13, 2013 4:04:14 AM UTC-7, Vlad from Moscow wrote:
>
>
> On Tuesday, March 12, 2013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wrote:
>>
>> 2013/3/12 Vlad from Moscow <vlad....@mail.ru>:=20
>> > At present the description of for example std::min_element is the=20
>> following=20
>> >=20
>> > 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) such=
 that for=20
>> any=20
>> > iterator j in the range=20
>> > [first,last) the following corresponding conditions hold: !(*j < *i) o=
r=20
>> > comp(*j, *i) =3D=3D false.=20
>> > Returns last if first =3D=3D last.=20
>> >=20
>> > However if to write=20
>> >=20
>> > int a[] =3D { 1, 2, 2, 1 };=20
>> >=20
>> > auto p =3D std::min_element( a, a + 4, std::less_equalj<int>() );=20
>>
>> (I assume, you mean std::less_equal) This code has undefined=20
>> behaviour, because it violates a general pre-condition described in=20
>> [alg.sorting] p3 that the template parameter named "Compare" shall=20
>> induce a strict weak ordering. std::less_equal<int> doesn't satisfy=20
>> this, because it is a reflexive relation.=20
>>
>> - Daniel=20
>>
> =20
> I wanted to say that there is no any need to specify the strict weak=20
> ordering for these algorithms. Any binary predicate can be used. So inste=
ad=20
> of undefined behavior that looks very silly we will get the last minimum =
or=20
> maximum. It is the only effective method to get the last extremum for=20
> sequences that have a forward iterator.
>

If it's an arbitrary binary predicate, then what exactly does the function=
=20
return? It certainly doesn't return the "minimum", as defined by some=20
ordering function, since an arbitrary binary predict does not induce an=20
ordering. It needs to define *some* kind of ordering. It may not need to be=
=20
strict-weak, but it needs to be something.

Furthermore, if you want the *last* element, you shouldn't be hijacking a=
=20
function that is intended to return the *first*. You should be asking for=
=20
min_last_element or something. Though I'm not sure how you would define=20
that.

--=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_316_21563909.1363177926053
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Wednesday, March 13, 2013 4:04:14 AM UTC-7, Vlad from Moscow wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><br>On Tuesday, March 12, 2=
013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wrote:<blockquote style=3D"margin=
:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);bord=
er-left-width:1px;border-left-style:solid" class=3D"gmail_quote">2013/3/12 =
Vlad from Moscow &lt;<a>vlad....@mail.ru</a>&gt;:
<br>&gt; At present the description of for example std::min_element is the =
following
<br>&gt;
<br>&gt; 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) =
such that for any
<br>&gt; iterator j in the range
<br>&gt; [first,last) the following corresponding conditions hold: !(*j &lt=
; *i) or
<br>&gt; comp(*j, *i) =3D=3D false.
<br>&gt; Returns last if first =3D=3D last.
<br>&gt;
<br>&gt; However if to write
<br>&gt;
<br>&gt; int a[] =3D { 1, 2, 2, 1 };
<br>&gt;
<br>&gt; auto p =3D std::min_element( a, a + 4, std::less_equalj&lt;int&gt;=
() );
<br>
<br>(I assume, you mean std::less_equal) This code has undefined
<br>behaviour, because it violates a general pre-condition described in
<br>[alg.sorting] p3 that the template parameter named "Compare" shall
<br>induce a strict weak ordering. std::less_equal&lt;int&gt; doesn't satis=
fy
<br>this, because it is a reflexive relation.
<br>
<br>- Daniel
<br></blockquote><div>&nbsp;</div><div>I wanted to say that there is no any=
 need to specify the strict weak ordering for these algorithms. Any&nbsp;bi=
nary predicate can be used. So instead of undefined behavior that looks ver=
y silly we will get the last minimum&nbsp;or maximum. It is the only effect=
ive method to get the last extremum for sequences that have a forward itera=
tor.</div></blockquote><div><br>If it's an arbitrary binary predicate, then=
 what exactly does the function return? It certainly doesn't return the "mi=
nimum", as defined by some ordering function, since an arbitrary binary pre=
dict does not induce an ordering. It needs to define <i>some</i> kind of or=
dering. It may not need to be strict-weak, but it needs to be something.<br=
><br>Furthermore, if you want the <i>last</i> element, you shouldn't be hij=
acking a function that is intended to return the <i>first</i>. You should b=
e asking for min_last_element or something. Though I'm not sure how you wou=
ld define that.<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_316_21563909.1363177926053--

.


Author: Jonathan Wakely <cxx@kayari.org>
Date: Wed, 13 Mar 2013 06:07:35 -0700 (PDT)
Raw View
------=_Part_1330_3802617.1363180055265
Content-Type: text/plain; charset=ISO-8859-1

On Wednesday, March 13, 2013 12:32:06 PM UTC, Nicol Bolas wrote:
>
>
> Furthermore, if you want the *last* element, you shouldn't be hijacking a
> function that is intended to return the *first*. You should be asking for
> min_last_element or something. Though I'm not sure how you would define
> that.
>

Yes, the proposal is a lot more than "changing descriptions" it would
change the meaning of the functions to be something different.

--

---
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_1330_3802617.1363180055265
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Wednesday, March 13, 2013 12:32:06 PM UTC, Nicol Bolas wrote:<blockquote=
 class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1=
px #ccc solid;padding-left: 1ex;"><br><div>Furthermore, if you want the <i>=
last</i> element, you shouldn't be hijacking a function that is intended to=
 return the <i>first</i>. You should be asking for min_last_element or some=
thing. Though I'm not sure how you would define that.<br></div></blockquote=
><div><br>Yes, the proposal is a lot more than "changing descriptions" it w=
ould change the meaning of the functions to be something different.<br></di=
v>

<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_1330_3802617.1363180055265--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 13 Mar 2013 07:00:32 -0700 (PDT)
Raw View
------=_Part_281_23668730.1363183232033
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


On Wednesday, March 13, 2013 4:32:06 PM UTC+4, Nicol Bolas wrote:
>
>
>
> On Wednesday, March 13, 2013 4:04:14 AM UTC-7, Vlad from Moscow wrote:
>>
>>
>> On Tuesday, March 12, 2013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wrote:
>>>
>>> 2013/3/12 Vlad from Moscow <vlad....@mail.ru>:=20
>>> > At present the description of for example std::min_element is the=20
>>> following=20
>>> >=20
>>> > 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) suc=
h that=20
>>> for any=20
>>> > iterator j in the range=20
>>> > [first,last) the following corresponding conditions hold: !(*j < *i)=
=20
>>> or=20
>>> > comp(*j, *i) =3D=3D false.=20
>>> > Returns last if first =3D=3D last.=20
>>> >=20
>>> > However if to write=20
>>> >=20
>>> > int a[] =3D { 1, 2, 2, 1 };=20
>>> >=20
>>> > auto p =3D std::min_element( a, a + 4, std::less_equalj<int>() );=20
>>>
>>> (I assume, you mean std::less_equal) This code has undefined=20
>>> behaviour, because it violates a general pre-condition described in=20
>>> [alg.sorting] p3 that the template parameter named "Compare" shall=20
>>> induce a strict weak ordering. std::less_equal<int> doesn't satisfy=20
>>> this, because it is a reflexive relation.=20
>>>
>>> - Daniel=20
>>>
>> =20
>> I wanted to say that there is no any need to specify the strict weak=20
>> ordering for these algorithms. Any binary predicate can be used. So inst=
ead=20
>> of undefined behavior that looks very silly we will get the last minimum=
 or=20
>> maximum. It is the only effective method to get the last extremum for=20
>> sequences that have a forward iterator.
>>
>
> If it's an arbitrary binary predicate, then what exactly does the functio=
n=20
> return? It certainly doesn't return the "minimum", as defined by some=20
> ordering function, since an arbitrary binary predict does not induce an=
=20
> ordering. It needs to define *some* kind of ordering. It may not need to=
=20
> be strict-weak, but it needs to be something.
>
> Furthermore, if you want the *last* element, you shouldn't be hijacking a=
=20
> function that is intended to return the *first*. You should be asking for=
=20
> min_last_element or something. Though I'm not sure how you would define=
=20
> that.
>
=20
If an arbitrary predicate is used then the function returns an iterator as=
=20
I described. I did not see any reasonable argument against my proposal. Do=
=20
you need to find the minimum element according to a strict weak order? And=
=20
what is the problem? Use operator < or some other comp function. Their=20
using satisfies fully the description I gave.
As for  to be hijacking then please answer the question how effectively to=
=20
find the last minimum element of a sequence with a forward iterator?

--=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_281_23668730.1363183232033
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br>On Wednesday, March 13, 2013 4:32:06 PM UTC+4, Nicol Bolas wrote:<block=
quote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-co=
lor: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"=
 class=3D"gmail_quote"><br><br>On Wednesday, March 13, 2013 4:04:14 AM UTC-=
7, Vlad from Moscow wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; p=
adding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width:=
 1px; border-left-style: solid;" class=3D"gmail_quote"><br>On Tuesday, Marc=
h 12, 2013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wrote:<blockquote 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"gmai=
l_quote">2013/3/12 Vlad from Moscow &lt;<a>vlad....@mail.ru</a>&gt;:
<br>&gt; At present the description of for example std::min_element is the =
following
<br>&gt;
<br>&gt; 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) =
such that for any
<br>&gt; iterator j in the range
<br>&gt; [first,last) the following corresponding conditions hold: !(*j &lt=
; *i) or
<br>&gt; comp(*j, *i) =3D=3D false.
<br>&gt; Returns last if first =3D=3D last.
<br>&gt;
<br>&gt; However if to write
<br>&gt;
<br>&gt; int a[] =3D { 1, 2, 2, 1 };
<br>&gt;
<br>&gt; auto p =3D std::min_element( a, a + 4, std::less_equalj&lt;int&gt;=
() );
<br>
<br>(I assume, you mean std::less_equal) This code has undefined
<br>behaviour, because it violates a general pre-condition described in
<br>[alg.sorting] p3 that the template parameter named "Compare" shall
<br>induce a strict weak ordering. std::less_equal&lt;int&gt; doesn't satis=
fy
<br>this, because it is a reflexive relation.
<br>
<br>- Daniel
<br></blockquote><div>&nbsp;</div><div>I wanted to say that there is no any=
 need to specify the strict weak ordering for these algorithms. Any&nbsp;bi=
nary predicate can be used. So instead of undefined behavior that looks ver=
y silly we will get the last minimum&nbsp;or maximum. It is the only effect=
ive method to get the last extremum for sequences that have a forward itera=
tor.</div></blockquote><div><br>If it's an arbitrary binary predicate, then=
 what exactly does the function return? It certainly doesn't return the "mi=
nimum", as defined by some ordering function, since an arbitrary binary pre=
dict does not induce an ordering. It needs to define <i>some</i> kind of or=
dering. It may not need to be strict-weak, but it needs to be something.<br=
><br>Furthermore, if you want the <i>last</i> element, you shouldn't be hij=
acking a function that is intended to return the <i>first</i>. You should b=
e asking for min_last_element or something. Though I'm not sure how you wou=
ld define that.<br></div></blockquote><div>&nbsp;</div><div>If an arbitrary=
 predicate is used then the function returns an iterator as I described. I =
did not see any reasonable argument against my proposal.&nbsp;Do you need t=
o find the minimum element according to&nbsp;a strict weak order? And what =
is the problem? Use operator &lt; or some other comp function.&nbsp;Their u=
sing&nbsp;satisfies fully the description I gave.</div><div>As for &nbsp;to=
 be hijacking then please answer the question how effectively to find the l=
ast minimum element of a sequence with a forward iterator?</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_281_23668730.1363183232033--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 13 Mar 2013 07:07:38 -0700 (PDT)
Raw View
------=_Part_43_12067121.1363183658298
Content-Type: text/plain; charset=ISO-8859-1


On Wednesday, March 13, 2013 5:07:35 PM UTC+4, Jonathan Wakely wrote:
>
> On Wednesday, March 13, 2013 12:32:06 PM UTC, Nicol Bolas wrote:
>>
>>
>> Furthermore, if you want the *last* element, you shouldn't be hijacking
>> a function that is intended to return the *first*. You should be asking
>> for min_last_element or something. Though I'm not sure how you would define
>> that.
>>
>
> Yes, the proposal is a lot more than "changing descriptions" it would
> change the meaning of the functions to be something different.
>


I can not agree with your statement because the meaning of the function is
not changed.  It is the meaning of the notion minimum that is enlarged. And
one of examples how this notion can be changed I showed in the first post.
That is there is not only the first minimum in a sequence but there is also
the last minimum in a sequence.


--

---
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_43_12067121.1363183658298
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Wednesday, March 13, 2013 5:07:35 PM UTC+4, Jonathan Wakely wrote:<b=
lockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;" class=3D"gmail_quote">On Wednesday, March 13, 2013 12:32:06 PM UTC, Ni=
col Bolas wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-lef=
t: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bord=
er-left-style: solid;" class=3D"gmail_quote"><br><div>Furthermore, if you w=
ant the <i>last</i> element, you shouldn't be hijacking a function that is =
intended to return the <i>first</i>. You should be asking for min_last_elem=
ent or something. Though I'm not sure how you would define that.<br></div><=
/blockquote><div><br>Yes, the proposal is a lot more than "changing descrip=
tions" it would change the meaning of the functions to be something differe=
nt.<br></div></blockquote><div>&nbsp;</div><div>&nbsp;</div><div>I can not =
agree with your statement because the meaning of the function is not change=
d.&nbsp; It is the meaning of the&nbsp;notion minimum&nbsp;that&nbsp;is enl=
arged.&nbsp;And one of examples how this notion can be changed I showed in =
the first post. That is there is not only the first minimum in a sequence b=
ut there is also the last minimum in&nbsp;a sequence.&nbsp;</div><div>&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_43_12067121.1363183658298--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 13 Mar 2013 07:16:44 -0700 (PDT)
Raw View
------=_Part_1784_18607326.1363184204167
Content-Type: text/plain; charset=ISO-8859-1


On Wednesday, March 13, 2013 5:07:35 PM UTC+4, Jonathan Wakely wrote:
>
> On Wednesday, March 13, 2013 12:32:06 PM UTC, Nicol Bolas wrote:
>>
>>
>> Furthermore, if you want the *last* element, you shouldn't be hijacking
>> a function that is intended to return the *first*. You should be asking
>> for min_last_element or something. Though I'm not sure how you would define
>> that.
>>
>
> Yes, the proposal is a lot more than "changing descriptions" it would
> change the meaning of the functions to be something different.
>

Also this argument as "would change the meaning of the functions to be
something different." is not serious enough. For example algorithm
std::accumulate can be successfuly used to count elements of a sequence in
some way. In such situations algorithms std::count or std::count_if usually
are useless. Does it mean that meaning of std::accumulate was changed? I
know many tasks that can be done with using different algorithms and I can
not prefer one algorithm compared with other algorithm that does the same
task. The simplest example is using std::find or std::find_if on the one
hand and std::any_of on the other hand.


--

---
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_1784_18607326.1363184204167
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Wednesday, March 13, 2013 5:07:35 PM UTC+4, Jonathan Wakely wrote:<b=
lockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;" class=3D"gmail_quote">On Wednesday, March 13, 2013 12:32:06 PM UTC, Ni=
col Bolas wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-lef=
t: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bord=
er-left-style: solid;" class=3D"gmail_quote"><br><div>Furthermore, if you w=
ant the <i>last</i> element, you shouldn't be hijacking a function that is =
intended to return the <i>first</i>. You should be asking for min_last_elem=
ent or something. Though I'm not sure how you would define that.<br></div><=
/blockquote><div><br>Yes, the proposal is a lot more than "changing descrip=
tions" it would change the meaning of the functions to be something differe=
nt.<br></div></blockquote><div>&nbsp;</div><div>Also this argument as&nbsp;=
"would change the meaning of the functions to be something different." is n=
ot serious enough. For example algorithm std::accumulate can be successfuly=
 used to count elements of a sequence in some way. In such situations algor=
ithms std::count or std::count_if usually are useless. Does&nbsp;it mean th=
at meaning of std::accumulate was changed? I know many tasks that can be do=
ne with using different algorithms and I can not prefer one algorithm compa=
red with other algorithm that does the same task. The simplest example is u=
sing std::find or std::find_if on the one hand&nbsp;and std::any_of on the =
other hand.&nbsp;</div><div>&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_1784_18607326.1363184204167--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 13 Mar 2013 07:31:10 -0700 (PDT)
Raw View
------=_Part_21_21044347.1363185070838
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Wednesday, March 13, 2013 7:00:32 AM UTC-7, Vlad from Moscow wrote:
>
>
> On Wednesday, March 13, 2013 4:32:06 PM UTC+4, Nicol Bolas wrote:
>>
>>
>>
>> On Wednesday, March 13, 2013 4:04:14 AM UTC-7, Vlad from Moscow wrote:
>>>
>>>
>>> On Tuesday, March 12, 2013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wrote:
>>>>
>>>> 2013/3/12 Vlad from Moscow <vlad....@mail.ru>:=20
>>>> > At present the description of for example std::min_element is the=20
>>>> following=20
>>>> >=20
>>>> > 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) su=
ch that=20
>>>> for any=20
>>>> > iterator j in the range=20
>>>> > [first,last) the following corresponding conditions hold: !(*j < *i)=
=20
>>>> or=20
>>>> > comp(*j, *i) =3D=3D false.=20
>>>> > Returns last if first =3D=3D last.=20
>>>> >=20
>>>> > However if to write=20
>>>> >=20
>>>> > int a[] =3D { 1, 2, 2, 1 };=20
>>>> >=20
>>>> > auto p =3D std::min_element( a, a + 4, std::less_equalj<int>() );=20
>>>>
>>>> (I assume, you mean std::less_equal) This code has undefined=20
>>>> behaviour, because it violates a general pre-condition described in=20
>>>> [alg.sorting] p3 that the template parameter named "Compare" shall=20
>>>> induce a strict weak ordering. std::less_equal<int> doesn't satisfy=20
>>>> this, because it is a reflexive relation.=20
>>>>
>>>> - Daniel=20
>>>>
>>> =20
>>> I wanted to say that there is no any need to specify the strict weak=20
>>> ordering for these algorithms. Any binary predicate can be used. So ins=
tead=20
>>> of undefined behavior that looks very silly we will get the last minimu=
m or=20
>>> maximum. It is the only effective method to get the last extremum for=
=20
>>> sequences that have a forward iterator.
>>>
>>
>> If it's an arbitrary binary predicate, then what exactly does the=20
>> function return? It certainly doesn't return the "minimum", as defined b=
y=20
>> some ordering function, since an arbitrary binary predict does not induc=
e=20
>> an ordering. It needs to define *some* kind of ordering. It may not need=
=20
>> to be strict-weak, but it needs to be something.
>>
>> Furthermore, if you want the *last* element, you shouldn't be hijacking=
=20
>> a function that is intended to return the *first*. You should be asking=
=20
>> for min_last_element or something. Though I'm not sure how you would def=
ine=20
>> that.
>>
> =20
> If an arbitrary predicate is used then the function returns an iterator a=
s=20
> I described.
>

At which point, the name of the function has lost all meaning. It's not=20
even finding a minimum value based on an ordering criteria; it's just=20
executing an arbitrary algorithm given an arbitrary criteria which *could*b=
e used to find minimum values.
=20

> I did not see any reasonable argument against my proposal.
>

That doesn't make you right.

The problem with your proposal is that it takes a function that had strong=
=20
semantics (get minimum according to ordering criteria) and turns it=20
something like std::foreach: an arbitrary computation box.

Or to put it another way, you shouldn't be able to use the same function to=
=20
get both the first and last minimum value. Not if you pass it the same=20
range of data.

Do you need to find the minimum element according to a strict weak order?=
=20
> And what is the problem? Use operator < or some other comp function. Thei=
r=20
> using satisfies fully the description I gave.
> As for  to be hijacking then please answer the question how effectively t=
o=20
> find the last minimum element of a sequence with a forward iterator?
>

Use reverse iterators. Problem solved.

--=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_21_21044347.1363185070838
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Wednesday, March 13, 2013 7:00:32 AM UTC-7, Vlad from Moscow wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><br>On Wednesday, March 13,=
 2013 4:32:06 PM UTC+4, Nicol Bolas wrote:<blockquote style=3D"margin:0px 0=
px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-lef=
t-width:1px;border-left-style:solid" class=3D"gmail_quote"><br><br>On Wedne=
sday, March 13, 2013 4:04:14 AM UTC-7, Vlad from Moscow wrote:<blockquote s=
tyle=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_quo=
te"><br>On Tuesday, March 12, 2013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wr=
ote:<blockquote style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-l=
eft-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" c=
lass=3D"gmail_quote">2013/3/12 Vlad from Moscow &lt;<a>vlad....@mail.ru</a>=
&gt;:
<br>&gt; At present the description of for example std::min_element is the =
following
<br>&gt;
<br>&gt; 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) =
such that for any
<br>&gt; iterator j in the range
<br>&gt; [first,last) the following corresponding conditions hold: !(*j &lt=
; *i) or
<br>&gt; comp(*j, *i) =3D=3D false.
<br>&gt; Returns last if first =3D=3D last.
<br>&gt;
<br>&gt; However if to write
<br>&gt;
<br>&gt; int a[] =3D { 1, 2, 2, 1 };
<br>&gt;
<br>&gt; auto p =3D std::min_element( a, a + 4, std::less_equalj&lt;int&gt;=
() );
<br>
<br>(I assume, you mean std::less_equal) This code has undefined
<br>behaviour, because it violates a general pre-condition described in
<br>[alg.sorting] p3 that the template parameter named "Compare" shall
<br>induce a strict weak ordering. std::less_equal&lt;int&gt; doesn't satis=
fy
<br>this, because it is a reflexive relation.
<br>
<br>- Daniel
<br></blockquote><div>&nbsp;</div><div>I wanted to say that there is no any=
 need to specify the strict weak ordering for these algorithms. Any&nbsp;bi=
nary predicate can be used. So instead of undefined behavior that looks ver=
y silly we will get the last minimum&nbsp;or maximum. It is the only effect=
ive method to get the last extremum for sequences that have a forward itera=
tor.</div></blockquote><div><br>If it's an arbitrary binary predicate, then=
 what exactly does the function return? It certainly doesn't return the "mi=
nimum", as defined by some ordering function, since an arbitrary binary pre=
dict does not induce an ordering. It needs to define <i>some</i> kind of or=
dering. It may not need to be strict-weak, but it needs to be something.<br=
><br>Furthermore, if you want the <i>last</i> element, you shouldn't be hij=
acking a function that is intended to return the <i>first</i>. You should b=
e asking for min_last_element or something. Though I'm not sure how you wou=
ld define that.<br></div></blockquote><div>&nbsp;</div><div>If an arbitrary=
 predicate is used then the function returns an iterator as I described.</d=
iv></blockquote><div><br>At which point, the name of the function has lost =
all meaning. It's not even finding a minimum value based on an ordering cri=
teria; it's just executing an arbitrary algorithm given an arbitrary criter=
ia which <i>could</i> be used to find minimum values.<br>&nbsp;</div><block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div>I did not see any reasonable ar=
gument against my proposal.</div></blockquote><div><br>That doesn't make yo=
u right.<br><br>The problem with your proposal is that it takes a function =
that had strong semantics (get minimum according to ordering criteria) and =
turns it something like std::foreach: an arbitrary computation box.<br><br>=
Or to put it another way, you shouldn't be able to use the same function to=
 get both the first and last minimum value. Not if you pass it the same ran=
ge of data.<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin:=
 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div>=
Do you need to find the minimum element according to&nbsp;a strict weak ord=
er? And what is the problem? Use operator &lt; or some other comp function.=
&nbsp;Their using&nbsp;satisfies fully the description I gave.</div><div>As=
 for &nbsp;to be hijacking then please answer the question how effectively =
to find the last minimum element of a sequence with a forward iterator?</di=
v></blockquote><div><br>Use reverse iterators. Problem solved.<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_21_21044347.1363185070838--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 13 Mar 2013 07:34:41 -0700 (PDT)
Raw View
------=_Part_676_9440752.1363185281502
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


On Tuesday, March 12, 2013 6:49:24 PM UTC+4, Vlad from Moscow wrote:
>
> At present the description of for example std::min_element is the followi=
ng
>
> 21 Returns: The *=EF=AC=81rst* iterator i in the range [first,last) such =
that for=20
> any iterator j in the range
> [first,last) the following corresponding conditions hold: !(*j < *i) or=
=20
> comp(*j, *i) =3D=3D false.
> Returns last if first =3D=3D last.
>
> However if to write=20
>
> int a[] =3D { 1, 2, 2, 1 };
>
> auto p =3D std::min_element( a, a + 4, std::less_equalj<int>() );
>
> we will get a predictable result. p will be equal to a + 3. That is the=
=20
> last minimum element will be found. However this behavior contradicts to=
=20
> the description because neither std::less_equal<int>()( *a, *( a + 3 ) ) =
=3D=3D=20
> false nor std::less_equal<int>()( *( a + 3 ), *a ) =3D=3D false.
>
> In my opinion there is no any reason to exclude using predicate=20
> std::less_equal (or similar) in such algorithms. Moreover it is the only=
=20
> effective method to find the last minimum/maximum element in a sequence=
=20
> that has forward iterator as for example std::forward_list.
>
> So the current description is incorrect. I am suggesting to change it to=
=20
> the following (for example for std::min_element)
>
> 21 Returns: Such iterator i in the range [first,last) that for any=20
> iterator j in the range
> [first,i) the following corresponding conditions hold: *i < *j or comp(*i=
,=20
> *j) =3D=3D true; and for any iterator j in the range (i, end)  the follow=
ing=20
> corresponding conditions hold !(*j < *i) or comp(*j, *i) =3D=3D false.
> Returns last if first =3D=3D last.
> =20
>
=20
Also I do not see any sense in descripttions of std::max and std::min. Let=
=20
assume that if two operands are equal you want to get the second operand.=
=20
It could be done simply if std::less_equal is used as comp predicate.=20
However accordingg to the current description the resuult is undefined as=
=20
Daniel was pointed out. What is the great sense to prohibit returning of=20
the second operand? I do not see any sense and there is no such a sense=20
except some individual dogms.
For example, algorithm std::min with predicate could be described (by=20
words) the following way
=20
return pred( b, a ) ? b : a;
=20
There is no any requirement about some sort of ordering
=20
You can substitute the predicate for operator < and you will get  'a' if=20
'a' is equal to 'b'. Or you can substitute the predicate for=20
std::less_equal and you will get 'b' if 'a' is equal to 'b'.
The body of the algoritthm does not depend on some sort of ordering.

--=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_676_9440752.1363185281502
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br>On Tuesday, March 12, 2013 6:49:24 PM UTC+4, Vlad from Moscow wrote:<bl=
ockquote 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: soli=
d;" class=3D"gmail_quote">At present the description of for example std::mi=
n_element is the following<div><br></div><div><div>21 Returns: The <b>=EF=
=AC=81rst</b> iterator i in the range [first,last) such that for any iterat=
or j in the range</div><div>[first,last) the following corresponding condit=
ions hold: !(*j &lt; *i) or comp(*j, *i) =3D=3D false.</div><div>Returns la=
st if first =3D=3D last.</div></div><div><br></div><div>However if to write=
&nbsp;</div><div><br></div><div>int a[] =3D { 1, 2, 2, 1 };</div><div><br><=
/div><div>auto p =3D std::min_element( a, a + 4, std::less_equalj&lt;int&gt=
;() );</div><div><br></div><div>we will get a predictable result. p will be=
 equal to a + 3. That is the last minimum element will be found. However th=
is behavior contradicts to the description because neither std::less_equal&=
lt;int&gt;()( *a, *( a + 3 ) ) =3D=3D false nor std::less_equal&lt;int&gt;(=
)( *( a + 3 ), *a ) =3D=3D false.</div><div><br></div><div>In my opinion th=
ere is no any reason to exclude using predicate std::less_equal (or similar=
) in such algorithms. Moreover it is the only effective method to find the =
last minimum/maximum element in a sequence that has forward iterator as for=
 example std::forward_list.</div><div><br></div><div>So the current descrip=
tion is incorrect. I am suggesting to change it to the following (for examp=
le for std::min_element)<br></div><div><br></div><div><div>21 Returns: Such=
&nbsp;iterator i in the range [first,last) that for any iterator j in the r=
ange</div><div>[first,i) the following corresponding conditions hold: *i &l=
t; *j or comp(*i, *j) =3D=3D true; and for any iterator j in the range (i, =
end) &nbsp;the following corresponding conditions hold !(*j &lt; *i) or com=
p(*j, *i) =3D=3D false.</div><div>Returns last if first =3D=3D last.</div><=
div>&nbsp;</div></div></blockquote><div>&nbsp;</div><div>Also I do not see =
any sense in&nbsp;descripttions of std::max and std::min. Let assume that i=
f two operands are equal&nbsp;you want to get the second operand. It could =
be done simply if std::less_equal is used as comp predicate. However accord=
ingg to the current description the resuult is undefined as Daniel was poin=
ted out. What is the great sense to prohibit returning of the second operan=
d? I do not see any sense and there is no such a sense except some individu=
al dogms.</div><div>For example, algorithm std::min with predicate could be=
 described (by words) the following way</div><div>&nbsp;</div><div>return p=
red( b, a ) ? b : a;</div><div>&nbsp;</div><div>There is no any requirement=
&nbsp;about some sort of ordering</div><div>&nbsp;</div><div>You can&nbsp;s=
ubstitute the predicate&nbsp;for operator &lt; and you will get&nbsp; 'a' i=
f 'a' is equal&nbsp;to 'b'. Or you can substitute the predicate for std::le=
ss_equal and you will get 'b' if 'a' is equal to 'b'.</div><div>The body of=
 the algoritthm does not depend on some sort of ordering.</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_676_9440752.1363185281502--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 13 Mar 2013 07:39:09 -0700 (PDT)
Raw View
------=_Part_134_9749598.1363185549048
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


On Wednesday, March 13, 2013 6:31:10 PM UTC+4, Nicol Bolas wrote:
>
>
>
> On Wednesday, March 13, 2013 7:00:32 AM UTC-7, Vlad from Moscow wrote:
>>
>>
>> On Wednesday, March 13, 2013 4:32:06 PM UTC+4, Nicol Bolas wrote:
>>>
>>>
>>>
>>> On Wednesday, March 13, 2013 4:04:14 AM UTC-7, Vlad from Moscow wrote:
>>>>
>>>>
>>>> On Tuesday, March 12, 2013 7:23:54 PM UTC+4, Daniel Kr=C3=BCgler wrote=
:
>>>>>
>>>>> 2013/3/12 Vlad from Moscow <vlad....@mail.ru>:=20
>>>>> > At present the description of for example std::min_element is the=
=20
>>>>> following=20
>>>>> >=20
>>>>> > 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) s=
uch that=20
>>>>> for any=20
>>>>> > iterator j in the range=20
>>>>> > [first,last) the following corresponding conditions hold: !(*j < *i=
)=20
>>>>> or=20
>>>>> > comp(*j, *i) =3D=3D false.=20
>>>>> > Returns last if first =3D=3D last.=20
>>>>> >=20
>>>>> > However if to write=20
>>>>> >=20
>>>>> > int a[] =3D { 1, 2, 2, 1 };=20
>>>>> >=20
>>>>> > auto p =3D std::min_element( a, a + 4, std::less_equalj<int>() );=
=20
>>>>>
>>>>> (I assume, you mean std::less_equal) This code has undefined=20
>>>>> behaviour, because it violates a general pre-condition described in=
=20
>>>>> [alg.sorting] p3 that the template parameter named "Compare" shall=20
>>>>> induce a strict weak ordering. std::less_equal<int> doesn't satisfy=
=20
>>>>> this, because it is a reflexive relation.=20
>>>>>
>>>>> - Daniel=20
>>>>>
>>>> =20
>>>> I wanted to say that there is no any need to specify the strict weak=
=20
>>>> ordering for these algorithms. Any binary predicate can be used. So in=
stead=20
>>>> of undefined behavior that looks very silly we will get the last minim=
um or=20
>>>> maximum. It is the only effective method to get the last extremum for=
=20
>>>> sequences that have a forward iterator.
>>>>
>>>
>>> If it's an arbitrary binary predicate, then what exactly does the=20
>>> function return? It certainly doesn't return the "minimum", as defined =
by=20
>>> some ordering function, since an arbitrary binary predict does not indu=
ce=20
>>> an ordering. It needs to define *some* kind of ordering. It may not=20
>>> need to be strict-weak, but it needs to be something.
>>>
>>> Furthermore, if you want the *last* element, you shouldn't be hijacking=
=20
>>> a function that is intended to return the *first*. You should be asking=
=20
>>> for min_last_element or something. Though I'm not sure how you would de=
fine=20
>>> that.
>>>
>> =20
>> If an arbitrary predicate is used then the function returns an iterator=
=20
>> as I described.
>>
>
> At which point, the name of the function has lost all meaning. It's not=
=20
> even finding a minimum value based on an ordering criteria; it's just=20
> executing an arbitrary algorithm given an arbitrary criteria which *could=
*be used to find minimum values.
> =20
>
>> I did not see any reasonable argument against my proposal.
>>
>
> That doesn't make you right.
>
> The problem with your proposal is that it takes a function that had stron=
g=20
> semantics (get minimum according to ordering criteria) and turns it=20
> something like std::foreach: an arbitrary computation box.
>
> Or to put it another way, you shouldn't be able to use the same function=
=20
> to get both the first and last minimum value. Not if you pass it the same=
=20
> range of data.
>
> Do you need to find the minimum element according to a strict weak order?=
=20
>> And what is the problem? Use operator < or some other comp function. The=
ir=20
>> using satisfies fully the description I gave.
>> As for  to be hijacking then please answer the question how effectively=
=20
>> to find the last minimum element of a sequence with a forward iterator?
>>
>
> Use reverse iterators. Problem solved.
>
=20
Does for example std::forward_list have reverse iterators?=20
I think that the semantics of the function is not changed. You can get the=
=20
minimum element as usual if you want. Only use a corresponding predicate=20
that satisfies the strict weak ordering.
=20

--=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_134_9749598.1363185549048
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br>On Wednesday, March 13, 2013 6:31:10 PM UTC+4, Nicol Bolas wrote:<block=
quote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-co=
lor: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"=
 class=3D"gmail_quote"><br><br>On Wednesday, March 13, 2013 7:00:32 AM UTC-=
7, Vlad from Moscow wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; p=
adding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width:=
 1px; border-left-style: solid;" class=3D"gmail_quote"><br>On Wednesday, Ma=
rch 13, 2013 4:32:06 PM UTC+4, Nicol Bolas wrote:<blockquote style=3D"margi=
n: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 2=
04); border-left-width: 1px; border-left-style: solid;" class=3D"gmail_quot=
e"><br><br>On Wednesday, March 13, 2013 4:04:14 AM UTC-7, Vlad from Moscow =
wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bo=
rder-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-st=
yle: solid;" class=3D"gmail_quote"><br>On Tuesday, March 12, 2013 7:23:54 P=
M UTC+4, Daniel Kr=C3=BCgler wrote:<blockquote style=3D"margin: 0px 0px 0px=
 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-le=
ft-width: 1px; border-left-style: solid;" class=3D"gmail_quote">2013/3/12 V=
lad from Moscow &lt;<a>vlad....@mail.ru</a>&gt;:
<br>&gt; At present the description of for example std::min_element is the =
following
<br>&gt;
<br>&gt; 21 Returns: The =EF=AC=81rst iterator i in the range [first,last) =
such that for any
<br>&gt; iterator j in the range
<br>&gt; [first,last) the following corresponding conditions hold: !(*j &lt=
; *i) or
<br>&gt; comp(*j, *i) =3D=3D false.
<br>&gt; Returns last if first =3D=3D last.
<br>&gt;
<br>&gt; However if to write
<br>&gt;
<br>&gt; int a[] =3D { 1, 2, 2, 1 };
<br>&gt;
<br>&gt; auto p =3D std::min_element( a, a + 4, std::less_equalj&lt;int&gt;=
() );
<br>
<br>(I assume, you mean std::less_equal) This code has undefined
<br>behaviour, because it violates a general pre-condition described in
<br>[alg.sorting] p3 that the template parameter named "Compare" shall
<br>induce a strict weak ordering. std::less_equal&lt;int&gt; doesn't satis=
fy
<br>this, because it is a reflexive relation.
<br>
<br>- Daniel
<br></blockquote><div>&nbsp;</div><div>I wanted to say that there is no any=
 need to specify the strict weak ordering for these algorithms. Any&nbsp;bi=
nary predicate can be used. So instead of undefined behavior that looks ver=
y silly we will get the last minimum&nbsp;or maximum. It is the only effect=
ive method to get the last extremum for sequences that have a forward itera=
tor.</div></blockquote><div><br>If it's an arbitrary binary predicate, then=
 what exactly does the function return? It certainly doesn't return the "mi=
nimum", as defined by some ordering function, since an arbitrary binary pre=
dict does not induce an ordering. It needs to define <i>some</i> kind of or=
dering. It may not need to be strict-weak, but it needs to be something.<br=
><br>Furthermore, if you want the <i>last</i> element, you shouldn't be hij=
acking a function that is intended to return the <i>first</i>. You should b=
e asking for min_last_element or something. Though I'm not sure how you wou=
ld define that.<br></div></blockquote><div>&nbsp;</div><div>If an arbitrary=
 predicate is used then the function returns an iterator as I described.</d=
iv></blockquote><div><br>At which point, the name of the function has lost =
all meaning. It's not even finding a minimum value based on an ordering cri=
teria; it's just executing an arbitrary algorithm given an arbitrary criter=
ia which <i>could</i> be used to find minimum values.<br>&nbsp;</div><block=
quote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-co=
lor: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"=
 class=3D"gmail_quote"><div>I did not see any reasonable argument against m=
y proposal.</div></blockquote><div><br>That doesn't make you right.<br><br>=
The problem with your proposal is that it takes a function that had strong =
semantics (get minimum according to ordering criteria) and turns it somethi=
ng like std::foreach: an arbitrary computation box.<br><br>Or to put it ano=
ther way, you shouldn't be able to use the same function to get both the fi=
rst and last minimum value. Not if you pass it the same range of data.<br><=
br></div><blockquote 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"><div>Do you need to find the minimum =
element according to&nbsp;a strict weak order? And what is the problem? Use=
 operator &lt; or some other comp function.&nbsp;Their using&nbsp;satisfies=
 fully the description I gave.</div><div>As for &nbsp;to be hijacking then =
please answer the question how effectively to find the last minimum element=
 of a sequence with a forward iterator?</div></blockquote><div><br>Use reve=
rse iterators. Problem solved.<br></div></blockquote><div>&nbsp;</div><div>=
Does for example std::forward_list have reverse iterators? </div><div>I thi=
nk that the semantics of the function&nbsp;is not changed. You can get the =
minimum element as usual if you want. Only use a corresponding predicate th=
at satisfies the strict weak ordering.</div><div>&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_134_9749598.1363185549048--

.


Author: Jonathan Wakely <cxx@kayari.org>
Date: Wed, 13 Mar 2013 08:55:32 -0700 (PDT)
Raw View
------=_Part_480_9609971.1363190132692
Content-Type: text/plain; charset=ISO-8859-1

On Wednesday, March 13, 2013 2:16:44 PM UTC, Vlad from Moscow wrote:
>
>
> On Wednesday, March 13, 2013 5:07:35 PM UTC+4, Jonathan Wakely wrote:
>>
>>
>> Yes, the proposal is a lot more than "changing descriptions" it would
>> change the meaning of the functions to be something different.
>>
>
> Also this argument as "would change the meaning of the functions to be
> something different." is not serious enough. For example algorithm
> std::accumulate can be successfuly used to count elements of a sequence in
> some way. In such situations algorithms std::count or std::count_if usually
> are useless. Does it mean that meaning of std::accumulate was changed?
>

No, because it's always been like that, so hasn't "changed".

If you "change" something now, it would be a "change".





> I know many tasks that can be done with using different algorithms and I
> can not prefer one algorithm compared with other algorithm that does the
> same task. The simplest example is using std::find or std::find_if on the
> one hand and std::any_of on the other hand.
>
>

--

---
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_480_9609971.1363190132692
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Wednesday, March 13, 2013 2:16:44 PM UTC, Vlad from Moscow wrote:<blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;"><br>On Wednesday, March 13, 2013 5:07=
:35 PM UTC+4, Jonathan Wakely wrote:<blockquote style=3D"margin:0px 0px 0px=
 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-widt=
h:1px;border-left-style:solid" class=3D"gmail_quote"><br><div>Yes, the prop=
osal is a lot more than "changing descriptions" it would change the meaning=
 of the functions to be something different.<br></div></blockquote><div>&nb=
sp;</div><div>Also this argument as&nbsp;"would change the meaning of the f=
unctions to be something different." is not serious enough. For example alg=
orithm std::accumulate can be successfuly used to count elements of a seque=
nce in some way. In such situations algorithms std::count or std::count_if =
usually are useless. Does&nbsp;it mean that meaning of std::accumulate was =
changed?</div></blockquote><div><br>No, because it's always been like that,=
 so hasn't "changed".<br><br>If you "change" something now, it would be a "=
change".<br><br><br><br>&nbsp;</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div>I know many tasks that can be done with using different algorith=
ms and I can not prefer one algorithm compared with other algorithm that do=
es the same task. The simplest example is using std::find or std::find_if o=
n the one hand&nbsp;and std::any_of on the other hand.&nbsp;</div><div>&nbs=
p;</div></blockquote>

<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_480_9609971.1363190132692--

.