Topic: General functions std::reverse and std::sort


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Mon, 24 Jun 2013 14:05:40 -0700 (PDT)
Raw View
------=_Part_41_8927140.1372107940446
Content-Type: text/plain; charset=ISO-8859-1

In most cases standard algorithms (and some containers' member functions)
std::sort and std:;reverse are called over a whole container. For example

[code]
std::forward_list<int> f;
// filling the list
f.sort();
// or
f.sort( std::greater<int>() );

std::vector<int>  v;
//filling the vector
std::sort( v.begin(), v.end() );
// or
std::sort( v.begin(), v.end(), std::greater<int>() );
[/code]

So I suggest to introduce general functions std::reverse and std::sort that
will accept  the reference to a container.

Below a demostrative example that illustrates the proposal

[code]
#include <iostream>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <forward_list>
#include <list>

namespace N1 // std
{

template <typename T>
void reverse( T &c )
{
 std::reverse( std::begin( c ), std::end( c ) );
}

template <typename T, typename Allocator>
void reverse( std::forward_list<T, Allocator> &f )
{
   f.reverse();
}

template <typename T, typename Allocator>
void reverse( std::list<T, Allocator> &l )
{
    l.reverse();
}
template <typename T>
void sort( T &c )
{
   std::sort( std::begin( c ), std::end( c ) );
}

template <typename T, typename Allocator>
void sort( std::forward_list<T, Allocator> &f )
{
   f.sort();
}

template <typename T, typename Allocator>
void sort( std::list<T, Allocator> &l )
{
   l.sort();
}
template <typename T, typename Compare>
void sort( T &c, Compare comp )
{
   std::sort( std::begin( c ), std::end( c ), comp );
}

template <typename T, typename Allocator, typename Compare>
void sort( std::forward_list<T, Allocator> &f, Compare comp )
{
   f.sort( comp );
}

template <typename T, typename Allocator, typename Compare>
void sort( std::list<T, Allocator> &l, Compare comp )
{
   l.sort( comp );
}
} // end of N1
int main()
{
   int a[3] = { 1, 2, 3 };
   std::forward_list<int> f( std::begin( a ), std::end( a ) );
   std::list<int> l( std::begin( a ), std::end( a ) );
   std::vector<int> v( std::begin( a ), std::end( a ) );

   std::cout << "a:\t";
   for ( int x : a ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "f:\t";
   for ( int x : f ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "l:\t";
   for ( int x : l ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "v:\t";
   for ( int x : v ) std::cout << x << ' ';
   std::cout << std::endl;

   N1::reverse( a );
   N1::reverse( f );
   N1::reverse( l );
   N1::reverse( v );

   std::cout << "a:\t";
   for ( int x : a ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "f:\t";
   for ( int x : f ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "l:\t";
   for ( int x : l ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "v:\t";
   for ( int x : v ) std::cout << x << ' ';
   std::cout << std::endl;

   N1::sort( a );
   N1::sort( f );
   N1::sort( l );
   N1::sort( v );

   std::cout << "a:\t";
   for ( int x : a ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "f:\t";
   for ( int x : f ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "l:\t";
   for ( int x : l ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "v:\t";
   for ( int x : v ) std::cout << x << ' ';
   std::cout << std::endl;

   N1::sort( a, std::greater<int>() );
   N1::sort( f, std::greater<int>() );
   N1::sort( l, std::greater<int>() );
   N1::sort( v, std::greater<int>() );

   std::cout << "a:\t";
   for ( int x : a ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "f:\t";
   for ( int x : f ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "l:\t";
   for ( int x : l ) std::cout << x << ' ';
   std::cout << std::endl;
   std::cout << "v:\t";
   for ( int x : v ) std::cout << x << ' ';
   std::cout << std::endl;
}
[/code]


--

---
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/.



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

<div>In most cases standard algorithms (and some containers' member functio=
ns) std::sort and std:;reverse are called over a whole container. For examp=
le</div><div>&nbsp;</div><div>[code]</div><div>std::forward_list&lt;int&gt;=
 f;</div><div>// filling the list</div><div>f.sort();</div><div>// or</div>=
<div>f.sort( std::greater&lt;int&gt;() );</div><div>&nbsp;</div><div>std::v=
ector&lt;int&gt; &nbsp;v;</div><div>//filling the vector</div><div>std::sor=
t( v.begin(), v.end() );</div><div>// or</div><div>std::sort( v.begin(), v.=
end(), std::greater&lt;int&gt;() );</div><div>[/code]</div><div>&nbsp;</div=
><div>So I suggest to introduce general functions std::reverse and std::sor=
t that will&nbsp;accept&nbsp; the reference to a container.</div><div>&nbsp=
;</div><div>Below a demostrative example that illustrates the proposal</div=
><div>&nbsp;</div><div>[code]</div><div>#include &lt;iostream&gt;</div><div=
>#include &lt;algorithm&gt;</div><div>#include &lt;iterator&gt;</div><div>#=
include &lt;functional&gt;</div><div>#include &lt;vector&gt;</div><div>#inc=
lude &lt;forward_list&gt;</div><div>#include &lt;list&gt;</div><div>&nbsp;<=
/div><div>namespace N1 // std</div><div>{</div><div>&nbsp;</div><div>templa=
te &lt;typename T&gt;<br>void reverse( T &amp;c )<br>{<br>&nbsp;std::revers=
e( std::begin( c ), std::end( c ) );<br>}</div><div>&nbsp;</div><div>templa=
te &lt;typename T, typename Allocator&gt;<br>void reverse( std::forward_lis=
t&lt;T, Allocator&gt; &amp;f )<br>{<br>&nbsp;&nbsp; f.reverse();<br>}</div>=
<div>&nbsp;</div><div><div>template &lt;typename T, typename Allocator&gt;<=
br>void reverse( std::list&lt;T, Allocator&gt; &amp;l )<br>{<br>  &nbsp;&nb=
sp;&nbsp; l.reverse();<br>}</div><div> </div></div><div>template &lt;typena=
me T&gt;<br>void sort( T &amp;c )<br>{<br>&nbsp;&nbsp; std::sort( std::begi=
n( c ), std::end( c ) );<br>}</div><div>&nbsp;</div><div>template &lt;typen=
ame T, typename Allocator&gt;<br>void sort( std::forward_list&lt;T, Allocat=
or&gt; &amp;f )<br>{<br>&nbsp;&nbsp; f.sort();<br>}</div><div>&nbsp;</div><=
div><div>template &lt;typename T, typename Allocator&gt;<br>void sort( std:=
:list&lt;T, Allocator&gt; &amp;l )<br>{<br>&nbsp;&nbsp;&nbsp;l.sort();<br>}=
</div><div> </div></div><div>template &lt;typename T, typename Compare&gt;<=
br>void sort( T &amp;c, Compare comp )<br>{<br>&nbsp;&nbsp; std::sort( std:=
:begin( c ), std::end( c ), comp );<br>}</div><div>&nbsp;</div><div>templat=
e &lt;typename T, typename Allocator, typename Compare&gt;<br>void sort( st=
d::forward_list&lt;T, Allocator&gt; &amp;f, Compare comp )<br>{<br>&nbsp;&n=
bsp; f.sort( comp );<br>}</div><div>&nbsp;</div><div><div>template &lt;type=
name T, typename Allocator, typename Compare&gt;<br>void sort( std::list&lt=
;T, Allocator&gt; &amp;l, Compare comp )<br>{<br>&nbsp;&nbsp; l.sort( comp =
);<br>}</div></div><div>}&nbsp;//&nbsp;end of N1<br></div><div>int main()</=
div><div>{<br>&nbsp;&nbsp; int a[3] =3D { 1, 2, 3 };<br>&nbsp;&nbsp; std::f=
orward_list&lt;int&gt; f( std::begin( a ), std::end( a ) );<br>&nbsp;&nbsp;=
 std::list&lt;int&gt; l( std::begin( a ), std::end( a ) );<br>&nbsp;&nbsp; =
std::vector&lt;int&gt; v( std::begin( a ), std::end( a ) );</div><div>&nbsp=
;</div><div>&nbsp;&nbsp; std::cout &lt;&lt; "a:\t";<br>&nbsp;&nbsp; for&nbs=
p;( int x&nbsp;: a ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>&nbsp;&nbsp; std=
::cout &lt;&lt; std::endl;<br>&nbsp;&nbsp; std::cout &lt;&lt; "f:\t";<br>&n=
bsp;&nbsp; for&nbsp;( int x&nbsp;:&nbsp;f ) std::cout &lt;&lt; x &lt;&lt; '=
 ';<br>&nbsp;&nbsp; std::cout &lt;&lt; std::endl;<br>&nbsp;&nbsp; std::cout=
 &lt;&lt; "l:\t";<br>  &nbsp;&nbsp; for ( int x :&nbsp;l ) std::cout &lt;&l=
t; x &lt;&lt; ' ';<br>  &nbsp;&nbsp; std::cout &lt;&lt; std::endl;<br>&nbsp=
;&nbsp; std::cout &lt;&lt; "v:\t";<br>&nbsp;&nbsp; for&nbsp;( int x&nbsp;: =
v ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>&nbsp;&nbsp; std::cout &lt;&lt; s=
td::endl;</div><div>&nbsp;</div><div>&nbsp;&nbsp; N1::reverse( a );<br>&nbs=
p;&nbsp; N1::reverse(&nbsp;f );<br>&nbsp;&nbsp; N1::reverse( l );<br>&nbsp;=
&nbsp; N1::reverse( v );</div><div>&nbsp;</div><div><div>  &nbsp;&nbsp; std=
::cout &lt;&lt; "a:\t";<br>  &nbsp;&nbsp; for ( int x : a ) std::cout &lt;&=
lt; x &lt;&lt; ' ';<br>  &nbsp;&nbsp; std::cout &lt;&lt; std::endl;<br>  &n=
bsp;&nbsp; std::cout &lt;&lt; "f:\t";<br>  &nbsp;&nbsp; for ( int x : f ) s=
td::cout &lt;&lt; x &lt;&lt; ' ';<br>  &nbsp;&nbsp; std::cout &lt;&lt; std:=
:endl;<br>  &nbsp;&nbsp; std::cout &lt;&lt; "l:\t";<br>    &nbsp;&nbsp; for=
 ( int x : l ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>    &nbsp;&nbsp; std::=
cout &lt;&lt; std::endl;<br>  &nbsp;&nbsp; std::cout &lt;&lt; "v:\t";<br>  =
&nbsp;&nbsp; for ( int x : v ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>  &nbs=
p;&nbsp; std::cout &lt;&lt; std::endl;</div><div>&nbsp;</div>&nbsp;&nbsp;&n=
bsp;N1::sort( a );<br>&nbsp;&nbsp; N1::sort(&nbsp;f );<br>&nbsp;&nbsp; N1::=
sort( l );<br>&nbsp;&nbsp; N1::sort( v );</div><div>&nbsp;</div><div>&nbsp;=
&nbsp; std::cout &lt;&lt; "a:\t";<br>  &nbsp;&nbsp; for ( int x : a ) std::=
cout &lt;&lt; x &lt;&lt; ' ';<br>  &nbsp;&nbsp; std::cout &lt;&lt; std::end=
l;<br>  &nbsp;&nbsp; std::cout &lt;&lt; "f:\t";<br>  &nbsp;&nbsp; for ( int=
 x : f ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>  &nbsp;&nbsp; std::cout &lt=
;&lt; std::endl;<br>  &nbsp;&nbsp; std::cout &lt;&lt; "l:\t";<br>  &nbsp;&n=
bsp; for ( int x : l ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>  &nbsp;&nbsp;=
 std::cout &lt;&lt; std::endl;<br>  &nbsp;&nbsp; std::cout &lt;&lt; "v:\t";=
<br>  &nbsp;&nbsp; for ( int x : v ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>=
  &nbsp;&nbsp; std::cout &lt;&lt; std::endl;</div><div>&nbsp;</div><div>&nb=
sp;&nbsp; N1::sort( a, std::greater&lt;int&gt;() );<br>&nbsp;&nbsp; N1::sor=
t( f, std::greater&lt;int&gt;() );<br>&nbsp;&nbsp; N1::sort( l, std::greate=
r&lt;int&gt;() );<br>&nbsp;&nbsp; N1::sort( v, std::greater&lt;int&gt;() );=
</div><div>&nbsp;</div><div><div>  &nbsp;&nbsp; std::cout &lt;&lt; "a:\t";<=
br>    &nbsp;&nbsp; for ( int x : a ) std::cout &lt;&lt; x &lt;&lt; ' ';<br=
>    &nbsp;&nbsp; std::cout &lt;&lt; std::endl;<br>    &nbsp;&nbsp; std::co=
ut &lt;&lt; "f:\t";<br>    &nbsp;&nbsp; for ( int x : f ) std::cout &lt;&lt=
; x &lt;&lt; ' ';<br>    &nbsp;&nbsp; std::cout &lt;&lt; std::endl;<br>    =
&nbsp;&nbsp; std::cout &lt;&lt; "l:\t";<br>    &nbsp;&nbsp; for ( int x : l=
 ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>  &nbsp;&nbsp; std::cout &lt;&lt; =
std::endl;<br>  &nbsp;&nbsp; std::cout &lt;&lt; "v:\t";<br>  &nbsp;&nbsp; f=
or ( int x : v ) std::cout &lt;&lt; x &lt;&lt; ' ';<br>  &nbsp;&nbsp; std::=
cout &lt;&lt; std::endl;</div>}<br>[/code]</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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_41_8927140.1372107940446--

.


Author: Zhihao Yuan <lichray@gmail.com>
Date: Mon, 24 Jun 2013 17:09:21 -0400
Raw View
On Mon, Jun 24, 2013 at 5:05 PM, Vlad from Moscow <vlad.moscow@mail.ru> wrote:
> In most cases standard algorithms (and some containers' member functions)
> std::sort and std:;reverse are called over a whole container. For example

Don't worry.  The Ranges study group is responsible for handling that.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/

--

---
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/.



.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Mon, 24 Jun 2013 14:11:50 -0700 (PDT)
Raw View
------=_Part_310_9248985.1372108310505
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

I am not worry I am making a proposal.

=D7=D4=CF=D2=CE=C9=CB, 25 =C9=C0=CE=D1 2013 =C7., 1:09:21 UTC+4 =D0=CF=CC=
=D8=DA=CF=D7=C1=D4=C5=CC=D8 Zhihao Yuan =CE=C1=D0=C9=D3=C1=CC:

> On Mon, Jun 24, 2013 at 5:05 PM, Vlad from Moscow <vlad....@mail.ru<javas=
cript:>>=20
> wrote:=20
> > In most cases standard algorithms (and some containers' member=20
> functions)=20
> > std::sort and std:;reverse are called over a whole container. For=20
> example=20
>
> Don't worry.  The Ranges study group is responsible for handling that.=20
>
> --=20
> Zhihao Yuan, ID lichray=20
> The best way to predict the future is to invent it.=20
> ___________________________________________________=20
> 4BSD -- http://4bsd.biz/=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/.



------=_Part_310_9248985.1372108310505
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

<div>I am not worry I am making a proposal.</div><div><br>=D7=D4=CF=D2=CE=
=C9=CB, 25 =C9=C0=CE=D1 2013&nbsp;=C7., 1:09:21 UTC+4 =D0=CF=CC=D8=DA=CF=D7=
=C1=D4=C5=CC=D8 Zhihao Yuan =CE=C1=D0=C9=D3=C1=CC:</div><blockquote style=
=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(20=
4, 204, 204); border-left-width: 1px; border-left-style: solid;" class=3D"g=
mail_quote">On Mon, Jun 24, 2013 at 5:05 PM, Vlad from Moscow &lt;<a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"KlhLQ8Wy8RQJ">v=
lad....@mail.ru</a>&gt; wrote:
<br>&gt; In most cases standard algorithms (and some containers' member fun=
ctions)
<br>&gt; std::sort and std:;reverse are called over a whole container. For =
example
<br>
<br>Don't worry. &nbsp;The Ranges study group is responsible for handling t=
hat.
<br>
<br>--
<br>Zhihao Yuan, ID lichray
<br>The best way to predict the future is to invent it.
<br>______________________________<wbr>_____________________
<br>4BSD -- <a href=3D"http://4bsd.biz/" target=3D"_blank">http://4bsd.biz/=
</a>
<br></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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_310_9248985.1372108310505--

.


Author: morwenn29@gmail.com
Date: Mon, 24 Jun 2013 16:10:17 -0700 (PDT)
Raw View
------=_Part_77_23829916.1372115417018
Content-Type: text/plain; charset=ISO-8859-1

Honestly, I would be more interested in std::reversed and std::sorted on
containers, which could be handy to use with rnge-based for loopd than in
std::sort and std::reverse.

--

---
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/.



------=_Part_77_23829916.1372115417018
Content-Type: text/html; charset=ISO-8859-1

Honestly, I would be more interested in std::reversed and std::sorted on containers, which could be handy to use with rnge-based for loopd than in std::sort and std::reverse.<br>

<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 email 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="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_77_23829916.1372115417018--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Mon, 24 Jun 2013 16:29:30 -0700 (PDT)
Raw View
------=_Part_54_2118830.1372116570853
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

You can make a corresponding proposal.

=D7=D4=CF=D2=CE=C9=CB, 25 =C9=C0=CE=D1 2013 =C7., 3:10:17 UTC+4 =D0=CF=CC=
=D8=DA=CF=D7=C1=D4=C5=CC=D8 morw...@gmail.com=20
=CE=C1=D0=C9=D3=C1=CC:

> Honestly, I would be more interested in std::reversed and std::sorted on=
=20
> containers, which could be handy to use with rnge-based for loopd than in=
=20
> std::sort and std::reverse.
>

--=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/.



------=_Part_54_2118830.1372116570853
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

<div>You can make a corresponding proposal.</div><div><br>=D7=D4=CF=D2=CE=
=C9=CB, 25 =C9=C0=CE=D1 2013&nbsp;=C7., 3:10:17 UTC+4 =D0=CF=CC=D8=DA=CF=D7=
=C1=D4=C5=CC=D8 morw...@gmail.com =CE=C1=D0=C9=D3=C1=CC:</div><blockquote s=
tyle=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rg=
b(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class=
=3D"gmail_quote">Honestly, I would be more interested in std::reversed and =
std::sorted on containers, which could be handy to use with rnge-based for =
loopd than in std::sort and std::reverse.<br></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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_54_2118830.1372116570853--

.


Author: morwenn29@gmail.com
Date: Tue, 25 Jun 2013 00:49:04 -0700 (PDT)
Raw View
------=_Part_235_13487530.1372146544839
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Well, I thought I could write one once, but there were many design choices=
=20
that I did not overcome: for example,
my first intent was to create generator objects in order to iterate through=
=20
them (the feature was really made for
range-based for loops and almost not to be used anywhere else), but my=20
choices when trying to implement it
seemed clumsy.

Moreover, that was close to Boost's range adapters, so I finally decided to=
=20
wait to see if a more generic
mecanism could work with range instead of having specialized generator=20
functions lost somewhere into
<utility> (or any other standard header).

The generator I implemented could be used like this for example:

    for (auto elem: std::reversed(container))
    {
        if (elem)
        {
            do_something();
            break;
        }
    }

Whatever, it's probably wiser to wait for ranges before trying anything=20
else, unless reversed/sorted are
useful enough by themselves to undergo a proposal.


Le mardi 25 juin 2013 01:29:30 UTC+2, Vlad from Moscow a =C3=A9crit :
>
> You can make a corresponding proposal.
>
> =D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F 2=
013 =D0=B3., 3:10:17 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C morw...@gmail.com=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=
=B0=D0=BB:
>
>> Honestly, I would be more interested in std::reversed and std::sorted on=
=20
>> containers, which could be handy to use with rnge-based for loopd than i=
n=20
>> std::sort and std::reverse.
>>
>

--=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/.



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

Well, I thought I could write one once, but there were many design choices =
that I did not overcome: for example,<br>my first intent was to create gene=
rator objects in order to iterate through them (the feature was really made=
 for<br>range-based for loops and almost not to be used anywhere else), but=
 my choices when trying to implement it<br>seemed clumsy.<br><br>Moreover, =
that was close to Boost's range adapters, so I finally decided to wait to s=
ee if a more generic<br>mecanism could work with range instead of having sp=
ecialized generator functions lost somewhere into<br>&lt;utility&gt; (or an=
y other standard header).<br><br>The generator I implemented could be used =
like this for example:<br><br>&nbsp;&nbsp;&nbsp; for (auto elem: std::rever=
sed(container))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp; if (elem)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do_somethin=
g();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp=
; }<br><br>Whatever, it's probably wiser to wait for ranges before trying a=
nything else, unless reversed/sorted are<br>useful enough by themselves to =
undergo a proposal.<br><br><br>Le mardi 25 juin 2013 01:29:30 UTC+2, Vlad f=
rom Moscow a =C3=A9crit&nbsp;:<blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">=
<div>You can make a corresponding proposal.</div><div><br>=D0=B2=D1=82=D0=
=BE=D1=80=D0=BD=D0=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F 2013&nbsp;=D0=B3.,=
 3:10:17 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=
=D0=BB=D1=8C <a>morw...@gmail.com</a> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=
=D0=BB:</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">Honestly, I would be more interested in std::=
reversed and std::sorted on containers, which could be handy to use with rn=
ge-based for loopd than in std::sort and std::reverse.<br></blockquote></bl=
ockquote>

<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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_235_13487530.1372146544839--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Thu, 27 Jun 2013 03:07:52 -0700 (PDT)
Raw View
------=_Part_1403_2856237.1372327672675
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Your ideas are different than mine. So they do not contradict each other. I=
=20
want to have general functions sort and reverse even for classes that have=
=20
no iterators. The only condition they must satisfy is the presence of =20
their own member functions sort and reverse.
For the demontsrative example I selected the approach used for std:;swap=20
that only to illustrate the idea. However it would be better to write these=
=20
functions based on conditions

std::is_member_function_pointer<decltype( &Container::reverse)>::value
std::is_member_function_pointer<decltype( &Container::sort)>::value
=20
=20

=D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F 201=
3 =D0=B3., 11:49:04 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C morw...@gmail.com=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:

> Well, I thought I could write one once, but there were many design choice=
s=20
> that I did not overcome: for example,
> my first intent was to create generator objects in order to iterate=20
> through them (the feature was really made for
> range-based for loops and almost not to be used anywhere else), but my=20
> choices when trying to implement it
> seemed clumsy.
>
> Moreover, that was close to Boost's range adapters, so I finally decided=
=20
> to wait to see if a more generic
> mecanism could work with range instead of having specialized generator=20
> functions lost somewhere into
> <utility> (or any other standard header).
>
> The generator I implemented could be used like this for example:
>
>     for (auto elem: std::reversed(container))
>     {
>         if (elem)
>         {
>             do_something();
>             break;
>         }
>     }
>
> Whatever, it's probably wiser to wait for ranges before trying anything=
=20
> else, unless reversed/sorted are
> useful enough by themselves to undergo a proposal.
>
>
> Le mardi 25 juin 2013 01:29:30 UTC+2, Vlad from Moscow a =C3=A9crit :
>>
>> You can make a corresponding proposal.
>>
>> =D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F =
2013 =D0=B3., 3:10:17 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=
=B0=D1=82=D0=B5=D0=BB=D1=8C morw...@gmail.com=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=
=D0=B0=D0=BB:
>>
>>> Honestly, I would be more interested in std::reversed and std::sorted o=
n=20
>>> containers, which could be handy to use with rnge-based for loopd than =
in=20
>>> std::sort and std::reverse.
>>>
>>

--=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/.



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

<div>Your ideas are different than mine. So they do not contradict each oth=
er. I want to have general functions sort and reverse even for classes that=
 have no iterators. The only condition they must satisfy is the presence of=
&nbsp; their own member functions sort and reverse.</div><div>For the demon=
tsrative example I selected the approach used for std:;swap that only to il=
lustrate the idea. However it would be better to write these functions base=
d on conditions</div><div><br>std::is_member_function_pointer&lt;decltype( =
&amp;Container::reverse)&gt;::value</div><div>std::is_member_function_point=
er&lt;decltype( &amp;Container::sort)&gt;::value</div><div>&nbsp;</div><div=
>&nbsp;</div><div><br>=D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 25 =D0=B8=
=D1=8E=D0=BD=D1=8F 2013&nbsp;=D0=B3., 11:49:04 UTC+4 =D0=BF=D0=BE=D0=BB=D1=
=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C morw...@gmail.com =D0=
=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</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">=
Well, I thought I could write one once, but there were many design choices =
that I did not overcome: for example,<br>my first intent was to create gene=
rator objects in order to iterate through them (the feature was really made=
 for<br>range-based for loops and almost not to be used anywhere else), but=
 my choices when trying to implement it<br>seemed clumsy.<br><br>Moreover, =
that was close to Boost's range adapters, so I finally decided to wait to s=
ee if a more generic<br>mecanism could work with range instead of having sp=
ecialized generator functions lost somewhere into<br>&lt;utility&gt; (or an=
y other standard header).<br><br>The generator I implemented could be used =
like this for example:<br><br>&nbsp;&nbsp;&nbsp; for (auto elem: std::rever=
sed(container))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp; if (elem)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do_somethin=
g();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp=
; }<br><br>Whatever, it's probably wiser to wait for ranges before trying a=
nything else, unless reversed/sorted are<br>useful enough by themselves to =
undergo a proposal.<br><br><br>Le mardi 25 juin 2013 01:29:30 UTC+2, Vlad f=
rom Moscow a =C3=A9crit&nbsp;:<blockquote style=3D"margin: 0px 0px 0px 0.8e=
x; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-wi=
dth: 1px; border-left-style: solid;" class=3D"gmail_quote"><div>You can mak=
e a corresponding proposal.</div><div><br>=D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=
=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F 2013&nbsp;=D0=B3., 3:10:17 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C <a>mo=
rw...@gmail.com</a> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</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">Honestly, I would be more interested in std::reverse=
d and std::sorted on containers, which could be handy to use with rnge-base=
d for loopd than in std::sort and std::reverse.<br></blockquote></blockquot=
e></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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_1403_2856237.1372327672675--

.


Author: Martinho Fernandes <martinho.fernandes@gmail.com>
Date: Thu, 27 Jun 2013 12:10:10 +0200
Raw View
On Thu, Jun 27, 2013 at 12:07 PM, Vlad from Moscow <vlad.moscow@mail.ru> wrote:
> Your ideas are different than mine. So they do not contradict each other. I
> want to have general functions sort and reverse even for classes that have
> no iterators. The only condition they must satisfy is the presence of  their
> own member functions sort and reverse.
> For the demontsrative example I selected the approach used for std:;swap
> that only to illustrate the idea. However it would be better to write these
> functions based on conditions
>
> std::is_member_function_pointer<decltype( &Container::reverse)>::value
> std::is_member_function_pointer<decltype( &Container::sort)>::value
>

The conditions you want are whether or not
`decltype(std::declval<Container>().reverse())` and
`decltype(std::declval<Container>().sort())` cause substitution
failures.

--

---
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/.



.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Thu, 27 Jun 2013 03:23:48 -0700 (PDT)
Raw View
------=_Part_186_30739171.1372328628123
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

So the task is to write appropriate overloaded functions based on these=20
conditions.

=DE=C5=D4=D7=C5=D2=C7, 27 =C9=C0=CE=D1 2013 =C7., 14:10:10 UTC+4 =D0=CF=CC=
=D8=DA=CF=D7=C1=D4=C5=CC=D8 R. Martinho Fernandes=20
=CE=C1=D0=C9=D3=C1=CC:

> On Thu, Jun 27, 2013 at 12:07 PM, Vlad from Moscow <vlad....@mail.ru<java=
script:>>=20
> wrote:=20
> > Your ideas are different than mine. So they do not contradict each=20
> other. I=20
> > want to have general functions sort and reverse even for classes that=
=20
> have=20
> > no iterators. The only condition they must satisfy is the presence of=
=20
>  their=20
> > own member functions sort and reverse.=20
> > For the demontsrative example I selected the approach used for std:;swa=
p=20
> > that only to illustrate the idea. However it would be better to write=
=20
> these=20
> > functions based on conditions=20
> >=20
> > std::is_member_function_pointer<decltype( &Container::reverse)>::value=
=20
> > std::is_member_function_pointer<decltype( &Container::sort)>::value=20
> >=20
>
> The conditions you want are whether or not=20
> `decltype(std::declval<Container>().reverse())` and=20
> `decltype(std::declval<Container>().sort())` cause substitution=20
> failures.=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/.



------=_Part_186_30739171.1372328628123
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

<div>So the task is to write appropriate overloaded functions based on thes=
e conditions.</div><div><br>=DE=C5=D4=D7=C5=D2=C7, 27 =C9=C0=CE=D1 2013&nbs=
p;=C7., 14:10:10 UTC+4 =D0=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8 R. Martinho Fer=
nandes =CE=C1=D0=C9=D3=C1=CC:</div><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">On Thu, Jun=
 27, 2013 at 12:07 PM, Vlad from Moscow &lt;<a href=3D"javascript:" target=
=3D"_blank" gdf-obfuscated-mailto=3D"oHuVj8Ka6m0J">vlad....@mail.ru</a>&gt;=
 wrote:
<br>&gt; Your ideas are different than mine. So they do not contradict each=
 other. I
<br>&gt; want to have general functions sort and reverse even for classes t=
hat have
<br>&gt; no iterators. The only condition they must satisfy is the presence=
 of &nbsp;their
<br>&gt; own member functions sort and reverse.
<br>&gt; For the demontsrative example I selected the approach used for std=
:;swap
<br>&gt; that only to illustrate the idea. However it would be better to wr=
ite these
<br>&gt; functions based on conditions
<br>&gt;
<br>&gt; std::is_member_function_<wbr>pointer&lt;decltype( &amp;Container::=
reverse)&gt;::value
<br>&gt; std::is_member_function_<wbr>pointer&lt;decltype( &amp;Container::=
sort)&gt;::value
<br>&gt;
<br>
<br>The conditions you want are whether or not
<br>`decltype(std::declval&lt;<wbr>Container&gt;().reverse())` and
<br>`decltype(std::declval&lt;<wbr>Container&gt;().sort())` cause substitut=
ion
<br>failures.
<br></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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_186_30739171.1372328628123--

.


Author: "'Vlad from Moscow' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Fri, 5 Oct 2018 07:51:40 -0700 (PDT)
Raw View
------=_Part_768_1080419618.1538751100822
Content-Type: multipart/alternative;
 boundary="----=_Part_769_353947659.1538751100823"

------=_Part_769_353947659.1538751100823
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

It seems using requires expressions it is not difficult to write the=20
general function sort and reverse.

I do not know yet requires expressions enough well but the initial=20
implementation an look for example the following way. It can be further=20
elaborated.

Here is a demonstrative program

#include <iostream>

#include <forward_list>
#include <vector>
#include <iterator>
#include <algorithm>


template <typename Container>
void sort( Container &container ) requires requires() { &Container::sort; }
{
    std::cout << "sort with requires is called.\n";=20
    container.sort();
}


template <typename Container>
void sort( Container &container )
{
    std::cout << "sort without requires is called.\n";=20
    std::sort( std::begin( container ), std::end( container ) );
}


template <typename Container>
void reverse( Container &container ) requires requires() { &Container::
reverse; }
{
    std::cout << "reverse with requires is called.\n";=20
    container.reverse();
}


template <typename Container>
void reverse( Container &container )
{
    std::cout << "reverse without requires is called.\n";=20
    std::reverse( std::begin( container ), std::end( container ) );
}


int main()
{
    std::forward_list<int> lst =3D { 3, 2, 1 };
   =20
    for ( const auto &item : lst ) std::cout << item << ' ';
    std::cout << '\n';
   =20
    sort( lst );


    for ( const auto &item : lst ) std::cout << item << ' ';
    std::cout << '\n';


    reverse( lst );



    for ( const auto &item : lst ) std::cout << item << ' ';
    std::cout << '\n';


    std::cout << '\n';
   =20
    std::vector<int> v =3D { 3, 2, 1 };


    for ( const auto &item : v ) std::cout << item << ' ';
    std::cout << '\n';
   =20
    sort( v );


    for ( const auto &item : v ) std::cout << item << ' ';
    std::cout << '\n';


    reverse( v );


    for ( const auto &item : v ) std::cout << item << ' ';
    std::cout << '\n';


    std::cout << '\n';


    int a[] =3D { 3, 2, 1 };
   =20
    for ( const auto &item : a ) std::cout << item << ' ';
    std::cout << '\n';
   =20
    sort( a );


    for ( const auto &item : a ) std::cout << item << ' ';
    std::cout << '\n';


    reverse( a );


    for ( const auto &item : a ) std::cout << item << ' ';
    std::cout << '\n';
}



So I am going to put your attention to this propoisal of general functions=
=20
*std::sort* and *std::reverse*. Of course another set of the function sort=
=20
should be with a second parameter that specifies the comparison.
=20

=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F 201=
3 =D0=B3., 14:23:48 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> So the task is to write appropriate overloaded functions based on these=
=20
> conditions.
>
> =D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F 2=
013 =D0=B3., 14:10:10 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=
=B0=D1=82=D0=B5=D0=BB=D1=8C R. Martinho=20
> Fernandes =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
>> On Thu, Jun 27, 2013 at 12:07 PM, Vlad from Moscow <vlad....@mail.ru>=20
>> wrote:=20
>> > Your ideas are different than mine. So they do not contradict each=20
>> other. I=20
>> > want to have general functions sort and reverse even for classes that=
=20
>> have=20
>> > no iterators. The only condition they must satisfy is the presence of=
=20
>>  their=20
>> > own member functions sort and reverse.=20
>> > For the demontsrative example I selected the approach used for=20
>> std:;swap=20
>> > that only to illustrate the idea. However it would be better to write=
=20
>> these=20
>> > functions based on conditions=20
>> >=20
>> > std::is_member_function_pointer<decltype( &Container::reverse)>::value=
=20
>> > std::is_member_function_pointer<decltype( &Container::sort)>::value=20
>> >=20
>>
>> The conditions you want are whether or not=20
>> `decltype(std::declval<Container>().reverse())` and=20
>> `decltype(std::declval<Container>().sort())` cause substitution=20
>> failures.=20
>>
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/4158f558-6d0c-4b70-9cf2-54afa3d9686d%40isocpp.or=
g.

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

<div dir=3D"ltr">It seems using requires expressions it is not difficult to=
 write the general function sort and reverse.<div><br></div><div>I do not k=
now yet requires expressions enough well but the initial implementation an =
look for example the following way. It can be further elaborated.</div><div=
><br></div><div>Here is a demonstrative program</div><div><br></div><div cl=
ass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-c=
olor: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-=
wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint=
"><span style=3D"color: #800;" class=3D"styled-by-prettify">#include</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #080;" class=3D"styled-by-prettify">&lt;iostream&gt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #080;" class=3D"styled-by-prettify">&lt;forward_list&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&lt;vector&gt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">#include</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" clas=
s=3D"styled-by-prettify">&lt;iterator&gt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">#include</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">&lt;algorithm&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Co=
ntainer</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> sort</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;=
" class=3D"styled-by-prettify">Container</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">container </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> requires requires</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">Container</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">sort</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #080;" class=3D"styled-by-prettify">&quot;sort with requ=
ires is called.\n&quot;</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> <br>=C2=A0 =C2=A0 container</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">sort</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">template</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Container</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> sort</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Cont=
ainer</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">container </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"s=
tyled-by-prettify">&quot;sort without requires is called.\n&quot;</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 std</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">sort</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> container </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">),</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">end</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> container </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">template</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typena=
me</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #606;" class=3D"styled-by-prettify">Container</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> reverse</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">Container</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">container </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> re=
quires requires</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Container</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">reverse</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">&quot;reverse with requi=
res is called.\n&quot;</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> <br>=C2=A0 =C2=A0 container</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">reverse</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">template</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Container</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> reverse</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">C=
ontainer</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">container </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">&quot;reverse without requires is called.\n&quot;</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">reverse</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> container </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">),</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">en=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> container </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br><br></span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> main</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">forward_lis=
t</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;int&g=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> lst </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">3</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify=
">2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">1</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">item </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> lst </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> item </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39; =
&#39;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #080;" class=3D"styled-by-prettify">&#39;\n&#39;</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=
=A0 sort</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> lst </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">for</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>item </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> lst </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> item </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">&#39; &#39;</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39;\=
n&#39;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=
=C2=A0 =C2=A0 reverse</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> lst </span><span style=3D"color: #660;" class=3D"styled-by-prettify">);<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br=
><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">for</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">item </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> lst </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> item </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080=
;" class=3D"styled-by-prettify">&#39; &#39;</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">&#39;\n&#39;</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettif=
y">&#39;\n&#39;</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">vector</span><span style=3D"color: #080;" class=3D"styled-=
by-prettify">&lt;int&gt;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> v </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">3</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D=
"styled-by-prettify">2</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">for</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">item </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> v </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> item </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify=
">&#39; &#39;</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
out </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">&#39;\n&#39;</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=
=C2=A0 =C2=A0 sort</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
v </span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=
=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>for</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">item </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> v <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> item </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"s=
tyled-by-prettify">&#39; &#39;</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
&#39;\n&#39;</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
><br>=C2=A0 =C2=A0 reverse</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> v </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
<br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">for</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">item </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> v </span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> item </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" clas=
s=3D"styled-by-prettify">&#39; &#39;</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">cout </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pretti=
fy">&#39;\n&#39;</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">cout </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39;\n&=
#39;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=
=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">[]</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">3</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;=
" class=3D"styled-by-prettify">1</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">for</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
onst</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">item </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">co=
ut </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> item </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">&#39; &#39;</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;=
" class=3D"styled-by-prettify">&#39;\n&#39;</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 sort</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 =C2=A0 </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">item </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> item </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39; &#39=
;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #080;" class=3D"styled-by-prettify">&#39;\n&#39;</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 =C2=A0 reverse</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">for</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">item </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> item </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39=
; &#39;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">&#39;\n&#39;</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br><br><br></span></div></code></div><div><br=
>So I am going to put your attention to this propoisal of general functions=
 <b>std::sort</b> and <b>std::reverse</b>. Of course another set of the fun=
ction sort should be with a second parameter that specifies the comparison.=
</div><div>=C2=A0<br><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=
=B8=D1=8E=D0=BD=D1=8F 2013 =D0=B3., 14:23:48 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow =D0=BD=D0=
=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div>So the task is to write appropriate overloaded functions based o=
n these conditions.</div><div><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=
=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F 2013=C2=A0=D0=B3., 14:10:10 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R. Marti=
nho Fernandes =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote =
style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(20=
4,204,204);border-left-width:1px;border-left-style:solid" class=3D"gmail_qu=
ote">On Thu, Jun 27, 2013 at 12:07 PM, Vlad from Moscow &lt;<a>vlad....@mai=
l.ru</a>&gt; wrote:
<br>&gt; Your ideas are different than mine. So they do not contradict each=
 other. I
<br>&gt; want to have general functions sort and reverse even for classes t=
hat have
<br>&gt; no iterators. The only condition they must satisfy is the presence=
 of =C2=A0their
<br>&gt; own member functions sort and reverse.
<br>&gt; For the demontsrative example I selected the approach used for std=
:;swap
<br>&gt; that only to illustrate the idea. However it would be better to wr=
ite these
<br>&gt; functions based on conditions
<br>&gt;
<br>&gt; std::is_member_function_<wbr>pointer&lt;decltype( &amp;Container::=
reverse)&gt;::value
<br>&gt; std::is_member_function_<wbr>pointer&lt;decltype( &amp;Container::=
sort)&gt;::value
<br>&gt;
<br>
<br>The conditions you want are whether or not
<br>`decltype(std::declval&lt;<wbr>Container&gt;().reverse())` and
<br>`decltype(std::declval&lt;<wbr>Container&gt;().sort())` cause substitut=
ion
<br>failures.
<br></blockquote></blockquote></div></div>

<p></p>

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

------=_Part_769_353947659.1538751100823--

------=_Part_768_1080419618.1538751100822--

.


Author: "'Vlad from Moscow' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Sun, 7 Oct 2018 06:53:31 -0700 (PDT)
Raw View
------=_Part_1270_1167202637.1538920411375
Content-Type: multipart/alternative;
 boundary="----=_Part_1271_1084920740.1538920411377"

------=_Part_1271_1084920740.1538920411377
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Maybe it is reasonable tp introduce also similar general functions  like=20
find, lower_bound, upper_bound, equal_range.

=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 5 =D0=BE=D0=BA=D1=82=D1=8F=D0=
=B1=D1=80=D1=8F 2018 =D0=B3., 18:51:40 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> It seems using requires expressions it is not difficult to write the=20
> general function sort and reverse.
>
> I do not know yet requires expressions enough well but the initial=20
> implementation an look for example the following way. It can be further=
=20
> elaborated.
>
> Here is a demonstrative program
>
> #include <iostream>
>
> #include <forward_list>
> #include <vector>
> #include <iterator>
> #include <algorithm>
>
>
> template <typename Container>
> void sort( Container &container ) requires requires() { &Container::sort;=
=20
> }
> {
>     std::cout << "sort with requires is called.\n";=20
>     container.sort();
> }
>
>
> template <typename Container>
> void sort( Container &container )
> {
>     std::cout << "sort without requires is called.\n";=20
>     std::sort( std::begin( container ), std::end( container ) );
> }
>
>
> template <typename Container>
> void reverse( Container &container ) requires requires() { &Container::
> reverse; }
> {
>     std::cout << "reverse with requires is called.\n";=20
>     container.reverse();
> }
>
>
> template <typename Container>
> void reverse( Container &container )
> {
>     std::cout << "reverse without requires is called.\n";=20
>     std::reverse( std::begin( container ), std::end( container ) );
> }
>
>
> int main()
> {
>     std::forward_list<int> lst =3D { 3, 2, 1 };
>    =20
>     for ( const auto &item : lst ) std::cout << item << ' ';
>     std::cout << '\n';
>    =20
>     sort( lst );
>
>
>     for ( const auto &item : lst ) std::cout << item << ' ';
>     std::cout << '\n';
>
>
>     reverse( lst );
>
>
>
>     for ( const auto &item : lst ) std::cout << item << ' ';
>     std::cout << '\n';
>
>
>     std::cout << '\n';
>    =20
>     std::vector<int> v =3D { 3, 2, 1 };
>
>
>     for ( const auto &item : v ) std::cout << item << ' ';
>     std::cout << '\n';
>    =20
>     sort( v );
>
>
>     for ( const auto &item : v ) std::cout << item << ' ';
>     std::cout << '\n';
>
>
>     reverse( v );
>
>
>     for ( const auto &item : v ) std::cout << item << ' ';
>     std::cout << '\n';
>
>
>     std::cout << '\n';
>
>
>     int a[] =3D { 3, 2, 1 };
>    =20
>     for ( const auto &item : a ) std::cout << item << ' ';
>     std::cout << '\n';
>    =20
>     sort( a );
>
>
>     for ( const auto &item : a ) std::cout << item << ' ';
>     std::cout << '\n';
>
>
>     reverse( a );
>
>
>     for ( const auto &item : a ) std::cout << item << ' ';
>     std::cout << '\n';
> }
>
>
>
> So I am going to put your attention to this propoisal of general function=
s=20
> *std::sort* and *std::reverse*. Of course another set of the function=20
> sort should be with a second parameter that specifies the comparison.
> =20
>
> =D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F 2=
013 =D0=B3., 14:23:48 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=
=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>> So the task is to write appropriate overloaded functions based on these=
=20
>> conditions.
>>
>> =D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F =
2013 =D0=B3., 14:10:10 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=
=B0=D1=82=D0=B5=D0=BB=D1=8C R. Martinho=20
>> Fernandes =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>>> On Thu, Jun 27, 2013 at 12:07 PM, Vlad from Moscow <vlad....@mail.ru>=
=20
>>> wrote:=20
>>> > Your ideas are different than mine. So they do not contradict each=20
>>> other. I=20
>>> > want to have general functions sort and reverse even for classes that=
=20
>>> have=20
>>> > no iterators. The only condition they must satisfy is the presence of=
=20
>>>  their=20
>>> > own member functions sort and reverse.=20
>>> > For the demontsrative example I selected the approach used for=20
>>> std:;swap=20
>>> > that only to illustrate the idea. However it would be better to write=
=20
>>> these=20
>>> > functions based on conditions=20
>>> >=20
>>> > std::is_member_function_pointer<decltype( &Container::reverse)>::valu=
e=20
>>> > std::is_member_function_pointer<decltype( &Container::sort)>::value=
=20
>>> >=20
>>>
>>> The conditions you want are whether or not=20
>>> `decltype(std::declval<Container>().reverse())` and=20
>>> `decltype(std::declval<Container>().sort())` cause substitution=20
>>> failures.=20
>>>
>>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/44e18e2a-13c7-46ec-8d5a-2d4b7acf0e95%40isocpp.or=
g.

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

<div dir=3D"ltr">Maybe it is reasonable tp introduce also similar general f=
unctions=C2=A0 like find, lower_bound, upper_bound, equal_range.<br><br>=D0=
=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 5 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=
=D1=80=D1=8F 2018 =D0=B3., 18:51:40 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=
=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow =D0=BD=D0=B0=D0=BF=
=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"margin:=
 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div =
dir=3D"ltr">It seems using requires expressions it is not difficult to writ=
e the general function sort and reverse.<div><br></div><div>I do not know y=
et requires expressions enough well but the initial implementation an look =
for example the following way. It can be further elaborated.</div><div><br>=
</div><div>Here is a demonstrative program</div><div><br></div><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px"><code><div><span style=3D"color:#800">#includ=
e</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&lt;i=
ostream&gt;</span><span style=3D"color:#000"><br><br></span><span style=3D"=
color:#800">#include</span><span style=3D"color:#000"> </span><span style=
=3D"color:#080">&lt;forward_list&gt;</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#800">#include</span><span style=3D"color:#000">=
 </span><span style=3D"color:#080">&lt;vector&gt;</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#800">#include</span><span style=3D=
"color:#000"> </span><span style=3D"color:#080">&lt;iterator&gt;</span><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#800">#include</span=
><span style=3D"color:#000"> </span><span style=3D"color:#080">&lt;algorith=
m&gt;</span><span style=3D"color:#000"><br><br><br></span><span style=3D"co=
lor:#008">template</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">&lt;</span><span style=3D"color:#008">typename</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">Container</span><span s=
tyle=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#008">void</span><span style=3D"color:#000"> sort</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#606">Container</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">&amp;</span><span style=3D"color:#000">container </spa=
n><span style=3D"color:#660">)</span><span style=3D"color:#000"> requires r=
equires</span><span style=3D"color:#660">()</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">&amp;</span><span style=3D"color:#606">Cont=
ainer</span><span style=3D"color:#660">::</span><span style=3D"color:#000">=
sort</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"col=
or:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#080">&quot;sort with requires=
 is called.\n&quot;</span><span style=3D"color:#660">;</span><span style=3D=
"color:#000"> <br>=C2=A0 =C2=A0 container</span><span style=3D"color:#660">=
..</span><span style=3D"color:#000">sort</span><span style=3D"color:#660">()=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}<=
/span><span style=3D"color:#000"><br><br><br></span><span style=3D"color:#0=
08">template</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">&lt;</span><span style=3D"color:#008">typename</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#606">Container</span><span style=
=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">void</span><span style=3D"color:#000"> sort</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Container</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">&amp;</span><span style=3D"color:#000">container </span>=
<span style=3D"color:#660">)</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 std</span><span style=3D"color:#660">::</span><span style=3D"color:#000=
">cout </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#080">&quot;sort without requires is c=
alled.\n&quot;</span><span style=3D"color:#660">;</span><span style=3D"colo=
r:#000"> <br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><s=
pan style=3D"color:#000">sort</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span=
 style=3D"color:#008">begin</span><span style=3D"color:#660">(</span><span =
style=3D"color:#000"> container </span><span style=3D"color:#660">),</span>=
<span style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><=
span style=3D"color:#008">end</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#000"> container </span><span style=3D"color:#660">)</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">);</span><sp=
an style=3D"color:#000"><br></span><span style=3D"color:#660">}</span><span=
 style=3D"color:#000"><br><br><br></span><span style=3D"color:#008">templat=
e</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;<=
/span><span style=3D"color:#008">typename</span><span style=3D"color:#000">=
 </span><span style=3D"color:#606">Container</span><span style=3D"color:#66=
0">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">void</span><span style=3D"color:#000"> reverse</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
06">Container</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">&amp;</span><span style=3D"color:#000">container </span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> requires requires</span=
><span style=3D"color:#660">()</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">{</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">&amp;</span><span style=3D"color:#606">Container</span><=
span style=3D"color:#660">::</span><span style=3D"color:#000">reverse</span=
><span style=3D"color:#660">;</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">}</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 s=
td</span><span style=3D"color:#660">::</span><span style=3D"color:#000">cou=
t </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#080">&quot;reverse with requires is called=
..\n&quot;</span><span style=3D"color:#660">;</span><span style=3D"color:#00=
0"> <br>=C2=A0 =C2=A0 container</span><span style=3D"color:#660">.</span><s=
pan style=3D"color:#000">reverse</span><span style=3D"color:#660">();</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</span><=
span style=3D"color:#000"><br><br><br></span><span style=3D"color:#008">tem=
plate</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
lt;</span><span style=3D"color:#008">typename</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#606">Container</span><span style=3D"color=
:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#008">void</span><span style=3D"color:#000"> reverse</span><span style=3D=
"color:#660">(</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#606">Container</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">&amp;</span><span style=3D"color:#000">container </span><span st=
yle=3D"color:#660">)</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</=
span><span style=3D"color:#660">::</span><span style=3D"color:#000">cout </=
span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> =
</span><span style=3D"color:#080">&quot;reverse without requires is called.=
\n&quot;</span><span style=3D"color:#660">;</span><span style=3D"color:#000=
"> <br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span st=
yle=3D"color:#000">reverse</span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span st=
yle=3D"color:#008">begin</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#000"> container </span><span style=3D"color:#660">),</span><sp=
an style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><spa=
n style=3D"color:#008">end</span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#000"> container </span><span style=3D"color:#660">)</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">);</span><span =
style=3D"color:#000"><br></span><span style=3D"color:#660">}</span><span st=
yle=3D"color:#000"><br><br><br></span><span style=3D"color:#008">int</span>=
<span style=3D"color:#000"> main</span><span style=3D"color:#660">()</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><s=
pan style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#=
660">::</span><span style=3D"color:#000">forward_list</span><span style=3D"=
color:#080">&lt;int&gt;</span><span style=3D"color:#000"> lst </span><span =
style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=3D=
"color:#066">3</span><span style=3D"color:#660">,</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#066">2</span><span style=3D"color:#66=
0">,</span><span style=3D"color:#000"> </span><span style=3D"color:#066">1<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">};</spa=
n><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color:#008">for</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">(</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">const</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">auto</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&amp;</span><span style=3D"color:#000">item </span><span st=
yle=3D"color:#660">:</span><span style=3D"color:#000"> lst </span><span sty=
le=3D"color:#660">)</span><span style=3D"color:#000"> std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span style=
=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> item </span><spa=
n style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#080">&#39; &#39;</span><span style=3D"color:#660">;</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"co=
lor:#660">::</span><span style=3D"color:#000">cout </span><span style=3D"co=
lor:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span style=3D"=
color:#080">&#39;\n&#39;</span><span style=3D"color:#660">;</span><span sty=
le=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 sort</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#000"> lst </span><span style=
=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">for</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">(</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">const</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#008">auto</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">&amp;</span><span style=3D"color:#000">item </sp=
an><span style=3D"color:#660">:</span><span style=3D"color:#000"> lst </spa=
n><span style=3D"color:#660">)</span><span style=3D"color:#000"> std</span>=
<span style=3D"color:#660">::</span><span style=3D"color:#000">cout </span>=
<span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> item =
</span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"=
> </span><span style=3D"color:#080">&#39; &#39;</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span =
style=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span =
style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660">;</spa=
n><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 reverse</span><span =
style=3D"color:#660">(</span><span style=3D"color:#000"> lst </span><span s=
tyle=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#008">for</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">const</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000">it=
em </span><span style=3D"color:#660">:</span><span style=3D"color:#000"> ls=
t </span><span style=3D"color:#660">)</span><span style=3D"color:#000"> std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">cout =
</span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"=
> item </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#080">&#39; &#39;</span><span style=3D=
"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span=
><span style=3D"color:#660">::</span><span style=3D"color:#000">cout </span=
><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 std</span><sp=
an style=3D"color:#660">::</span><span style=3D"color:#000">cout </span><sp=
an style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><=
span style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660">;</=
span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 std</sp=
an><span style=3D"color:#660">::</span><span style=3D"color:#000">vector</s=
pan><span style=3D"color:#080">&lt;int&gt;</span><span style=3D"color:#000"=
> v </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#066">3</span><span style=3D"color:#660">,</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#066">2</span><span s=
tyle=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">1</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">};</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </=
span><span style=3D"color:#008">for</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">const</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">auto</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">&amp;</span><span style=3D"color:#000">item </span><sp=
an style=3D"color:#660">:</span><span style=3D"color:#000"> v </span><span =
style=3D"color:#660">)</span><span style=3D"color:#000"> std</span><span st=
yle=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span st=
yle=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> item </span><=
span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span=
><span style=3D"color:#080">&#39; &#39;</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D=
"color:#660">::</span><span style=3D"color:#000">cout </span><span style=3D=
"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span style=
=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660">;</span><span=
 style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 sort</span><span =
style=3D"color:#660">(</span><span style=3D"color:#000"> v </span><span sty=
le=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:#008">for</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">const</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">&amp;</span><span style=3D"color:#000">item <=
/span><span style=3D"color:#660">:</span><span style=3D"color:#000"> v </sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> std</span=
><span style=3D"color:#660">::</span><span style=3D"color:#000">cout </span=
><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> item=
 </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&#39; &#39;</span><span style=3D"color=
:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span=
 style=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span=
 style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660">;</sp=
an><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 reverse</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#000"> v </span><span st=
yle=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:#008">for</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">const</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">&amp;</span><span style=3D"color:#000">item <=
/span><span style=3D"color:#660">:</span><span style=3D"color:#000"> v </sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> std</span=
><span style=3D"color:#660">::</span><span style=3D"color:#000">cout </span=
><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> item=
 </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&#39; &#39;</span><span style=3D"color=
:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span=
 style=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span=
 style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660">;</sp=
an><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 std</span><span sty=
le=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span sty=
le=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660">;</span><=
span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"c=
olor:#008">int</span><span style=3D"color:#000"> a</span><span style=3D"col=
or:#660">[]</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#660=
">{</span><span style=3D"color:#000"> </span><span style=3D"color:#066">3</=
span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#066">2</span><span style=3D"color:#660">,</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#066">1</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#660">};</span><span style=3D=
"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"colo=
r:#008">for</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">(</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
const</span><span style=3D"color:#000"> </span><span style=3D"color:#008">a=
uto</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&am=
p;</span><span style=3D"color:#000">item </span><span style=3D"color:#660">=
:</span><span style=3D"color:#000"> a </span><span style=3D"color:#660">)</=
span><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</s=
pan><span style=3D"color:#000">cout </span><span style=3D"color:#660">&lt;&=
lt;</span><span style=3D"color:#000"> item </span><span style=3D"color:#660=
">&lt;&lt;</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
80">&#39; &#39;</span><span style=3D"color:#660">;</span><span style=3D"col=
or:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><s=
pan style=3D"color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#080">&#39;\n&#=
39;</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br=
>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 sort</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#000"> a </span><span style=3D"color:#660">);</spa=
n><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">for</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">(</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#008">const</span><span style=3D"color:#000"> </span><span style=3D"color=
:#008">auto</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">&amp;</span><span style=3D"color:#000">item </span><span style=3D"colo=
r:#660">:</span><span style=3D"color:#000"> a </span><span style=3D"color:#=
660">)</span><span style=3D"color:#000"> std</span><span style=3D"color:#66=
0">::</span><span style=3D"color:#000">cout </span><span style=3D"color:#66=
0">&lt;&lt;</span><span style=3D"color:#000"> item </span><span style=3D"co=
lor:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span style=3D"=
color:#080">&#39; &#39;</span><span style=3D"color:#660">;</span><span styl=
e=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::<=
/span><span style=3D"color:#000">cout </span><span style=3D"color:#660">&lt=
;&lt;</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&=
#39;\n&#39;</span><span style=3D"color:#660">;</span><span style=3D"color:#=
000"><br><br><br>=C2=A0 =C2=A0 reverse</span><span style=3D"color:#660">(</=
span><span style=3D"color:#000"> a </span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">for</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">(</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#008">const</span><span style=3D"color:#000"> </span><span style=3D"color=
:#008">auto</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">&amp;</span><span style=3D"color:#000">item </span><span style=3D"colo=
r:#660">:</span><span style=3D"color:#000"> a </span><span style=3D"color:#=
660">)</span><span style=3D"color:#000"> std</span><span style=3D"color:#66=
0">::</span><span style=3D"color:#000">cout </span><span style=3D"color:#66=
0">&lt;&lt;</span><span style=3D"color:#000"> item </span><span style=3D"co=
lor:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span style=3D"=
color:#080">&#39; &#39;</span><span style=3D"color:#660">;</span><span styl=
e=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::<=
/span><span style=3D"color:#000">cout </span><span style=3D"color:#660">&lt=
;&lt;</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&=
#39;\n&#39;</span><span style=3D"color:#660">;</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#660">}</span><span style=3D"color:#00=
0"><br><br><br></span></div></code></div><div><br>So I am going to put your=
 attention to this propoisal of general functions <b>std::sort</b> and <b>s=
td::reverse</b>. Of course another set of the function sort should be with =
a second parameter that specifies the comparison.</div><div>=C2=A0<br><br>=
=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F 201=
3 =D0=B3., 14:23:48 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=
=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div>So the task is to wr=
ite appropriate overloaded functions based on these conditions.</div><div><=
br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F =
2013=C2=A0=D0=B3., 14:10:10 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=
=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R. Martinho Fernandes =D0=BD=D0=B0=D0=BF=
=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote style=3D"margin:0px 0px 0px 0.8e=
x;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px=
;border-left-style:solid" class=3D"gmail_quote">On Thu, Jun 27, 2013 at 12:=
07 PM, Vlad from Moscow &lt;<a>vlad....@mail.ru</a>&gt; wrote:
<br>&gt; Your ideas are different than mine. So they do not contradict each=
 other. I
<br>&gt; want to have general functions sort and reverse even for classes t=
hat have
<br>&gt; no iterators. The only condition they must satisfy is the presence=
 of =C2=A0their
<br>&gt; own member functions sort and reverse.
<br>&gt; For the demontsrative example I selected the approach used for std=
:;swap
<br>&gt; that only to illustrate the idea. However it would be better to wr=
ite these
<br>&gt; functions based on conditions
<br>&gt;
<br>&gt; std::is_member_function_<wbr>pointer&lt;decltype( &amp;Container::=
reverse)&gt;::value
<br>&gt; std::is_member_function_<wbr>pointer&lt;decltype( &amp;Container::=
sort)&gt;::value
<br>&gt;
<br>
<br>The conditions you want are whether or not
<br>`decltype(std::declval&lt;<wbr>Container&gt;().reverse())` and
<br>`decltype(std::declval&lt;<wbr>Container&gt;().sort())` cause substitut=
ion
<br>failures.
<br></blockquote></blockquote></div></div></blockquote></div>

<p></p>

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

------=_Part_1271_1084920740.1538920411377--

------=_Part_1270_1167202637.1538920411375--

.


Author: Justin Bassett <jbassett271@gmail.com>
Date: Sun, 7 Oct 2018 09:32:01 -0700
Raw View
--0000000000000f3d0c0577a60cbd
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I believe ranges will fill this role. I'm not entirely familiar with it, so
I'm not sure if it allows you to write `std::ranges::sort(some_std_list)`
(I remember hearing that it does, though), but I believe it otherwise does
what you are talking about.

On Sun, Oct 7, 2018 at 6:53 AM 'Vlad from Moscow' via ISO C++ Standard -
Future Proposals <std-proposals@isocpp.org> wrote:

> Maybe it is reasonable tp introduce also similar general functions  like
> find, lower_bound, upper_bound, equal_range.
>
> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 5 =D0=BE=D0=BA=D1=82=D1=8F=D0=
=B1=D1=80=D1=8F 2018 =D0=B3., 18:51:40 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>> It seems using requires expressions it is not difficult to write the
>> general function sort and reverse.
>>
>> I do not know yet requires expressions enough well but the initial
>> implementation an look for example the following way. It can be further
>> elaborated.
>>
>> Here is a demonstrative program
>>
>> #include <iostream>
>>
>> #include <forward_list>
>> #include <vector>
>> #include <iterator>
>> #include <algorithm>
>>
>>
>> template <typename Container>
>> void sort( Container &container ) requires requires() { &Container::sort=
;
>> }
>> {
>>     std::cout << "sort with requires is called.\n";
>>     container.sort();
>> }
>>
>>
>> template <typename Container>
>> void sort( Container &container )
>> {
>>     std::cout << "sort without requires is called.\n";
>>     std::sort( std::begin( container ), std::end( container ) );
>> }
>>
>>
>> template <typename Container>
>> void reverse( Container &container ) requires requires() { &Container::
>> reverse; }
>> {
>>     std::cout << "reverse with requires is called.\n";
>>     container.reverse();
>> }
>>
>>
>> template <typename Container>
>> void reverse( Container &container )
>> {
>>     std::cout << "reverse without requires is called.\n";
>>     std::reverse( std::begin( container ), std::end( container ) );
>> }
>>
>>
>> int main()
>> {
>>     std::forward_list<int> lst =3D { 3, 2, 1 };
>>
>>     for ( const auto &item : lst ) std::cout << item << ' ';
>>     std::cout << '\n';
>>
>>     sort( lst );
>>
>>
>>     for ( const auto &item : lst ) std::cout << item << ' ';
>>     std::cout << '\n';
>>
>>
>>     reverse( lst );
>>
>>
>>
>>     for ( const auto &item : lst ) std::cout << item << ' ';
>>     std::cout << '\n';
>>
>>
>>     std::cout << '\n';
>>
>>     std::vector<int> v =3D { 3, 2, 1 };
>>
>>
>>     for ( const auto &item : v ) std::cout << item << ' ';
>>     std::cout << '\n';
>>
>>     sort( v );
>>
>>
>>     for ( const auto &item : v ) std::cout << item << ' ';
>>     std::cout << '\n';
>>
>>
>>     reverse( v );
>>
>>
>>     for ( const auto &item : v ) std::cout << item << ' ';
>>     std::cout << '\n';
>>
>>
>>     std::cout << '\n';
>>
>>
>>     int a[] =3D { 3, 2, 1 };
>>
>>     for ( const auto &item : a ) std::cout << item << ' ';
>>     std::cout << '\n';
>>
>>     sort( a );
>>
>>
>>     for ( const auto &item : a ) std::cout << item << ' ';
>>     std::cout << '\n';
>>
>>
>>     reverse( a );
>>
>>
>>     for ( const auto &item : a ) std::cout << item << ' ';
>>     std::cout << '\n';
>> }
>>
>>
>>
>> So I am going to put your attention to this propoisal of general
>> functions *std::sort* and *std::reverse*. Of course another set of the
>> function sort should be with a second parameter that specifies the
>> comparison.
>>
>>
>> =D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F =
2013 =D0=B3., 14:23:48 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=
=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow
>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>
>>> So the task is to write appropriate overloaded functions based on these
>>> conditions.
>>>
>>> =D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F=
 2013 =D0=B3., 14:10:10 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=
=B0=D1=82=D0=B5=D0=BB=D1=8C R. Martinho
>>> Fernandes =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>
>>>> On Thu, Jun 27, 2013 at 12:07 PM, Vlad from Moscow <vlad....@mail.ru>
>>>> wrote:
>>>> > Your ideas are different than mine. So they do not contradict each
>>>> other. I
>>>> > want to have general functions sort and reverse even for classes tha=
t
>>>> have
>>>> > no iterators. The only condition they must satisfy is the presence o=
f
>>>>  their
>>>> > own member functions sort and reverse.
>>>> > For the demontsrative example I selected the approach used for
>>>> std:;swap
>>>> > that only to illustrate the idea. However it would be better to writ=
e
>>>> these
>>>> > functions based on conditions
>>>> >
>>>> > std::is_member_function_pointer<decltype(
>>>> &Container::reverse)>::value
>>>> > std::is_member_function_pointer<decltype( &Container::sort)>::value
>>>> >
>>>>
>>>> The conditions you want are whether or not
>>>> `decltype(std::declval<Container>().reverse())` and
>>>> `decltype(std::declval<Container>().sort())` cause substitution
>>>> failures.
>>>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/44e18e2a-13c=
7-46ec-8d5a-2d4b7acf0e95%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/44e18e2a-13=
c7-46ec-8d5a-2d4b7acf0e95%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAPuuy5dSTjC5U17XZDXU5%3D3Qj%3DtPMRSJ9%3DBr%2B3M=
nX3ytL8DFyg%40mail.gmail.com.

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

<div dir=3D"ltr">I believe ranges will fill this role. I&#39;m not entirely=
 familiar with it, so I&#39;m not sure if it allows you to write `std::rang=
es::sort(some_std_list)` (I remember hearing that it does, though), but I b=
elieve it otherwise does what you are talking about.</div><br><div class=3D=
"gmail_quote"><div dir=3D"ltr">On Sun, Oct 7, 2018 at 6:53 AM &#39;Vlad fro=
m Moscow&#39; via ISO C++ Standard - Future Proposals &lt;<a href=3D"mailto=
:std-proposals@isocpp.org">std-proposals@isocpp.org</a>&gt; wrote:<br></div=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Maybe it is reasonable tp =
introduce also similar general functions=C2=A0 like find, lower_bound, uppe=
r_bound, equal_range.<br><br>=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 5 =
=D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2018 =D0=B3., 18:51:40 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad =
from Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D=
"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr">It seems using requires expressions it=
 is not difficult to write the general function sort and reverse.<div><br><=
/div><div>I do not know yet requires expressions enough well but the initia=
l implementation an look for example the following way. It can be further e=
laborated.</div><div><br></div><div>Here is a demonstrative program</div><d=
iv><br></div><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px"><code><div><span style=
=3D"color:#800">#include</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#080">&lt;iostream&gt;</span><span style=3D"color:#000"><br><br=
></span><span style=3D"color:#800">#include</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&lt;forward_list&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#800">#include</span><span =
style=3D"color:#000"> </span><span style=3D"color:#080">&lt;vector&gt;</spa=
n><span style=3D"color:#000"><br></span><span style=3D"color:#800">#include=
</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&lt;it=
erator&gt;</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#800">#include</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#080">&lt;algorithm&gt;</span><span style=3D"color:#000"><br><br><br></s=
pan><span style=3D"color:#008">template</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">type=
name</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Co=
ntainer</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#008">void</span><span style=3D"color:#=
000"> sort</span><span style=3D"color:#660">(</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#606">Container</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">&amp;</span><span style=3D"color:=
#000">container </span><span style=3D"color:#660">)</span><span style=3D"co=
lor:#000"> requires requires</span><span style=3D"color:#660">()</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">&amp;</span><span styl=
e=3D"color:#606">Container</span><span style=3D"color:#660">::</span><span =
style=3D"color:#000">sort</span><span style=3D"color:#660">;</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">}</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</=
span><span style=3D"color:#000">cout </span><span style=3D"color:#660">&lt;=
&lt;</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&q=
uot;sort with requires is called.\n&quot;</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"> <br>=C2=A0 =C2=A0 container</span><span=
 style=3D"color:#660">.</span><span style=3D"color:#000">sort</span><span s=
tyle=3D"color:#660">();</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#660">}</span><span style=3D"color:#000"><br><br><br></span><=
span style=3D"color:#008">template</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Contain=
er</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><=
br></span><span style=3D"color:#008">void</span><span style=3D"color:#000">=
 sort</span><span style=3D"color:#660">(</span><span style=3D"color:#000"> =
</span><span style=3D"color:#606">Container</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000"=
>container </span><span style=3D"color:#660">)</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#660">{</span><span style=3D"color:#00=
0"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span st=
yle=3D"color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#080">&quot;sort with=
out requires is called.\n&quot;</span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#000"> <br>=C2=A0 =C2=A0 std</span><span style=3D"color:=
#660">::</span><span style=3D"color:#000">sort</span><span style=3D"color:#=
660">(</span><span style=3D"color:#000"> std</span><span style=3D"color:#66=
0">::</span><span style=3D"color:#008">begin</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#000"> container </span><span style=3D"colo=
r:#660">),</span><span style=3D"color:#000"> std</span><span style=3D"color=
:#660">::</span><span style=3D"color:#008">end</span><span style=3D"color:#=
660">(</span><span style=3D"color:#000"> container </span><span style=3D"co=
lor:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">}</span><span style=3D"color:#000"><br><br><br></span><span style=3D"co=
lor:#008">template</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">&lt;</span><span style=3D"color:#008">typename</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">Container</span><span s=
tyle=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#008">void</span><span style=3D"color:#000"> reverse</span><=
span style=3D"color:#660">(</span><span style=3D"color:#000"> </span><span =
style=3D"color:#606">Container</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">&amp;</span><span style=3D"color:#000">container </=
span><span style=3D"color:#660">)</span><span style=3D"color:#000"> require=
s requires</span><span style=3D"color:#660">()</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">&amp;</span><span style=3D"color:#606">C=
ontainer</span><span style=3D"color:#660">::</span><span style=3D"color:#00=
0">reverse</span><span style=3D"color:#660">;</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">}</span><span style=3D"color:#000"><=
br></span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br=
>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D=
"color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#080">&quot;reverse with re=
quires is called.\n&quot;</span><span style=3D"color:#660">;</span><span st=
yle=3D"color:#000"> <br>=C2=A0 =C2=A0 container</span><span style=3D"color:=
#660">.</span><span style=3D"color:#000">reverse</span><span style=3D"color=
:#660">();</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#660">}</span><span style=3D"color:#000"><br><br><br></span><span style=3D=
"color:#008">template</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span =
style=3D"color:#000"> </span><span style=3D"color:#606">Container</span><sp=
an style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#008">void</span><span style=3D"color:#000"> reverse</sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Container</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">&amp;</span><span style=3D"color:#000">containe=
r </span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"=
color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#080">&quot;reverse without =
requires is called.\n&quot;</span><span style=3D"color:#660">;</span><span =
style=3D"color:#000"> <br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660=
">::</span><span style=3D"color:#000">reverse</span><span style=3D"color:#6=
60">(</span><span style=3D"color:#000"> std</span><span style=3D"color:#660=
">::</span><span style=3D"color:#008">begin</span><span style=3D"color:#660=
">(</span><span style=3D"color:#000"> container </span><span style=3D"color=
:#660">),</span><span style=3D"color:#000"> std</span><span style=3D"color:=
#660">::</span><span style=3D"color:#008">end</span><span style=3D"color:#6=
60">(</span><span style=3D"color:#000"> container </span><span style=3D"col=
or:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#66=
0">}</span><span style=3D"color:#000"><br><br><br></span><span style=3D"col=
or:#008">int</span><span style=3D"color:#000"> main</span><span style=3D"co=
lor:#660">()</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><sp=
an style=3D"color:#660">::</span><span style=3D"color:#000">forward_list</s=
pan><span style=3D"color:#080">&lt;int&gt;</span><span style=3D"color:#000"=
> lst </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> </=
span><span style=3D"color:#066">3</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#066">2</span><span=
 style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#066">1</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">};</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#008">for</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">const</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000">it=
em </span><span style=3D"color:#660">:</span><span style=3D"color:#000"> ls=
t </span><span style=3D"color:#660">)</span><span style=3D"color:#000"> std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">cout =
</span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"=
> item </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#080">&#39; &#39;</span><span style=3D=
"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span=
><span style=3D"color:#660">::</span><span style=3D"color:#000">cout </span=
><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 sor=
t</span><span style=3D"color:#660">(</span><span style=3D"color:#000"> lst =
</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br><=
br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">for</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=3D"=
color:#000"> </span><span style=3D"color:#008">const</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">auto</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">&amp;</span><span style=3D"colo=
r:#000">item </span><span style=3D"color:#660">:</span><span style=3D"color=
:#000"> lst </span><span style=3D"color:#660">)</span><span style=3D"color:=
#000"> std</span><span style=3D"color:#660">::</span><span style=3D"color:#=
000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"c=
olor:#000"> item </span><span style=3D"color:#660">&lt;&lt;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#080">&#39; &#39;</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0=
 std</span><span style=3D"color:#660">::</span><span style=3D"color:#000">c=
out </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#=
000"> </span><span style=3D"color:#080">&#39;\n&#39;</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 rev=
erse</span><span style=3D"color:#660">(</span><span style=3D"color:#000"> l=
st </span><span style=3D"color:#660">);</span><span style=3D"color:#000"><b=
r><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">for</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">const</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&amp;</span><span style=
=3D"color:#000">item </span><span style=3D"color:#660">:</span><span style=
=3D"color:#000"> lst </span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span=
 style=3D"color:#000"> item </span><span style=3D"color:#660">&lt;&lt;</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#080">&#39; &#39;=
</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"=
color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#080">&#39;\n&#39;</span><sp=
an style=3D"color:#660">;</span><span style=3D"color:#000"><br><br><br>=C2=
=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"col=
or:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#080">&#39;\n&#39;</span><span=
 style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =
<br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">vector</span><span style=3D"color:#080">&lt;int&gt;</span><=
span style=3D"color:#000"> v </span><span style=3D"color:#660">=3D</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#066">3</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">2</span><span style=3D"color:#660">,</span><span style=3D"color:=
#000"> </span><span style=3D"color:#066">1</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br=
><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">for</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">const</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&amp;</span><span style=
=3D"color:#000">item </span><span style=3D"color:#660">:</span><span style=
=3D"color:#000"> v </span><span style=3D"color:#660">)</span><span style=3D=
"color:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"=
color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span sty=
le=3D"color:#000"> item </span><span style=3D"color:#660">&lt;&lt;</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#080">&#39; &#39;</sp=
an><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0=
 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"color:=
#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"=
color:#000"> </span><span style=3D"color:#080">&#39;\n&#39;</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=
=C2=A0 =C2=A0 sort</span><span style=3D"color:#660">(</span><span style=3D"=
color:#000"> v </span><span style=3D"color:#660">);</span><span style=3D"co=
lor:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">for</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">(</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#008">const</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">auto</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">&amp;</span><spa=
n style=3D"color:#000">item </span><span style=3D"color:#660">:</span><span=
 style=3D"color:#000"> v </span><span style=3D"color:#660">)</span><span st=
yle=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span sty=
le=3D"color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><sp=
an style=3D"color:#000"> item </span><span style=3D"color:#660">&lt;&lt;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#080">&#39; &#3=
9;</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"=
color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#080">&#39;\n&#39;</span><sp=
an style=3D"color:#660">;</span><span style=3D"color:#000"><br><br><br>=C2=
=A0 =C2=A0 reverse</span><span style=3D"color:#660">(</span><span style=3D"=
color:#000"> v </span><span style=3D"color:#660">);</span><span style=3D"co=
lor:#000"><br><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">for</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">(</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#008">const</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">auto</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">&amp;</span><spa=
n style=3D"color:#000">item </span><span style=3D"color:#660">:</span><span=
 style=3D"color:#000"> v </span><span style=3D"color:#660">)</span><span st=
yle=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span sty=
le=3D"color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><sp=
an style=3D"color:#000"> item </span><span style=3D"color:#660">&lt;&lt;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#080">&#39; &#3=
9;</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"=
color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#080">&#39;\n&#39;</span><sp=
an style=3D"color:#660">;</span><span style=3D"color:#000"><br><br><br>=C2=
=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"col=
or:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#080">&#39;\n&#39;</span><span=
 style=3D"color:#660">;</span><span style=3D"color:#000"><br><br><br>=C2=A0=
 =C2=A0 </span><span style=3D"color:#008">int</span><span style=3D"color:#0=
00"> a</span><span style=3D"color:#660">[]</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">{</span><span style=3D"color:#000"> </span=
><span style=3D"color:#066">3</span><span style=3D"color:#660">,</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#066">2</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D=
"color:#066">1</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">};</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =
=C2=A0 </span><span style=3D"color:#008">for</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">(</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">const</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">&amp;</span><span style=3D"color:#000">item <=
/span><span style=3D"color:#660">:</span><span style=3D"color:#000"> a </sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> std</span=
><span style=3D"color:#660">::</span><span style=3D"color:#000">cout </span=
><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> item=
 </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">&#39; &#39;</span><span style=3D"color=
:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span=
 style=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span=
 style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#660">;</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 sort</spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#000"> a </span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008">for</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">const</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">auto</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000"=
>item </span><span style=3D"color:#660">:</span><span style=3D"color:#000">=
 a </span><span style=3D"color:#660">)</span><span style=3D"color:#000"> st=
d</span><span style=3D"color:#660">::</span><span style=3D"color:#000">cout=
 </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000=
"> item </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#080">&#39; &#39;</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</s=
pan><span style=3D"color:#660">::</span><span style=3D"color:#000">cout </s=
pan><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#6=
60">;</span><span style=3D"color:#000"><br><br><br>=C2=A0 =C2=A0 reverse</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#000"> a </span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br><br=
>=C2=A0 =C2=A0 </span><span style=3D"color:#008">for</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">const</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">auto</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000=
">item </span><span style=3D"color:#660">:</span><span style=3D"color:#000"=
> a </span><span style=3D"color:#660">)</span><span style=3D"color:#000"> s=
td</span><span style=3D"color:#660">::</span><span style=3D"color:#000">cou=
t </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#00=
0"> item </span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#080">&#39; &#39;</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</s=
pan><span style=3D"color:#660">::</span><span style=3D"color:#000">cout </s=
pan><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#080">&#39;\n&#39;</span><span style=3D"color:#6=
60">;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660=
">}</span><span style=3D"color:#000"><br><br><br></span></div></code></div>=
<div><br>So I am going to put your attention to this propoisal of general f=
unctions <b>std::sort</b> and <b>std::reverse</b>. Of course another set of=
 the function sort should be with a second parameter that specifies the com=
parison.</div><div>=C2=A0<br><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=B3=
, 27 =D0=B8=D1=8E=D0=BD=D1=8F 2013 =D0=B3., 14:23:48 UTC+4 =D0=BF=D0=BE=D0=
=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow =
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div>So the task is to write appropriate overloaded functions based=
 on these conditions.</div><div><br>=D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80=D0=
=B3, 27 =D0=B8=D1=8E=D0=BD=D1=8F 2013=C2=A0=D0=B3., 14:10:10 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R. Marti=
nho Fernandes =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote =
style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(20=
4,204,204);border-left-width:1px;border-left-style:solid" class=3D"gmail_qu=
ote">On Thu, Jun 27, 2013 at 12:07 PM, Vlad from Moscow &lt;<a>vlad....@mai=
l.ru</a>&gt; wrote:
<br>&gt; Your ideas are different than mine. So they do not contradict each=
 other. I
<br>&gt; want to have general functions sort and reverse even for classes t=
hat have
<br>&gt; no iterators. The only condition they must satisfy is the presence=
 of =C2=A0their
<br>&gt; own member functions sort and reverse.
<br>&gt; For the demontsrative example I selected the approach used for std=
:;swap
<br>&gt; that only to illustrate the idea. However it would be better to wr=
ite these
<br>&gt; functions based on conditions
<br>&gt;
<br>&gt; std::is_member_function_pointer&lt;decltype( &amp;Container::rever=
se)&gt;::value
<br>&gt; std::is_member_function_pointer&lt;decltype( &amp;Container::sort)=
&gt;::value
<br>&gt;
<br>
<br>The conditions you want are whether or not
<br>`decltype(std::declval&lt;Container&gt;().reverse())` and
<br>`decltype(std::declval&lt;Container&gt;().sort())` cause substitution
<br>failures.
<br></blockquote></blockquote></div></div></blockquote></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/44e18e2a-13c7-46ec-8d5a-2d4b7acf0e95%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/44e18e2a-13c7-=
46ec-8d5a-2d4b7acf0e95%40isocpp.org</a>.<br>
</blockquote></div>

<p></p>

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

--0000000000000f3d0c0577a60cbd--

.


Author: "'Vlad from Moscow' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Fri, 30 Nov 2018 07:37:31 -0800 (PST)
Raw View
------=_Part_3584_1202523852.1543592251795
Content-Type: multipart/alternative;
 boundary="----=_Part_3585_1081225702.1543592251796"

------=_Part_3585_1081225702.1543592251796
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I'm sorry.

It would be more correctly to define the function the following way=20
changing the return type tas it is shown
template <typename Container>=20
Container & sort( Container &container ) requires requires() { &Container::
sort; }=20
{=20
    container.sort();
   =20
    return container;
}=20
 =20
template <typename Container>=20
Container & sort( Container &container )=20
{=20
    std::sort( std::begin( container ), std::end( container ) );=20
   =20
    return container;
}


Consider for example this question of a beginner as me at Stackoverflow=20
https://stackoverflow.com/questions/53557881/checking-if-two-strings-are-an=
agram#

It is required to determine whether two strings are anagrams of each other.

One of approaches is to sort the strings and compare them.

Using the functions above the function that determines whether strings are=
=20
anagrams can be written easy.

#include <iostream>
#include <iomanip>=20
#include <string>=20
#include <iterator>=20
#include <algorithm>=20
 =20
template <typename Container>=20
Container & sort( Container &container ) requires requires() { &Container::
sort; }=20
{=20
    container.sort();
   =20
    return container;
}=20
 =20
template <typename Container>=20
Container & sort( Container &container )=20
{=20
    std::sort( std::begin( container ), std::end( container ) );=20
   =20
    return container;
}


bool isAnagrams( std::string s1, std::string s2 )
{
    return std::size( s1 ) =3D=3D std::size( s2 ) and sort( s1 ) =3D=3D sor=
t( s2 );
}


int main()
{
    std::cout << "Enter two strings: ";
   =20
    std::string s1, s2;
   =20
    std::cin >> s1 >> s2;
   =20
    std::cout << "The strings " << std::quoted( s1 )
              << " and " << std::quoted( s2 )=20
              << " are " << ( isAnagrams( s1, s2 ) ? "" : "not" )
              << " anagrams of each other.\n";
}


Its output might look like

Enter two strings: act tac
The strings "act" and "tac" are anagrams of each other.






=D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F 201=
3 =D0=B3., 1:05:40 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> In most cases standard algorithms (and some containers' member functions)=
=20
> std::sort and std:;reverse are called over a whole container. For example
> =20
> [code]
> std::forward_list<int> f;
> // filling the list
> f.sort();
> // or
> f.sort( std::greater<int>() );
> =20
> std::vector<int>  v;
> //filling the vector
> std::sort( v.begin(), v.end() );
> // or
> std::sort( v.begin(), v.end(), std::greater<int>() );
> [/code]
> =20
> So I suggest to introduce general functions std::reverse and std::sort=20
> that will accept  the reference to a container.
> =20
> Below a demostrative example that illustrates the proposal
> =20
> [code]
> #include <iostream>
> #include <algorithm>
> #include <iterator>
> #include <functional>
> #include <vector>
> #include <forward_list>
> #include <list>
> =20
> namespace N1 // std
> {
> =20
> template <typename T>
> void reverse( T &c )
> {
>  std::reverse( std::begin( c ), std::end( c ) );
> }
> =20
> template <typename T, typename Allocator>
> void reverse( std::forward_list<T, Allocator> &f )
> {
>    f.reverse();
> }
> =20
> template <typename T, typename Allocator>
> void reverse( std::list<T, Allocator> &l )
> {
>     l.reverse();
> }
> template <typename T>
> void sort( T &c )
> {
>    std::sort( std::begin( c ), std::end( c ) );
> }
> =20
> template <typename T, typename Allocator>
> void sort( std::forward_list<T, Allocator> &f )
> {
>    f.sort();
> }
> =20
> template <typename T, typename Allocator>
> void sort( std::list<T, Allocator> &l )
> {
>    l.sort();
> }
> template <typename T, typename Compare>
> void sort( T &c, Compare comp )
> {
>    std::sort( std::begin( c ), std::end( c ), comp );
> }
> =20
> template <typename T, typename Allocator, typename Compare>
> void sort( std::forward_list<T, Allocator> &f, Compare comp )
> {
>    f.sort( comp );
> }
> =20
> template <typename T, typename Allocator, typename Compare>
> void sort( std::list<T, Allocator> &l, Compare comp )
> {
>    l.sort( comp );
> }
> } // end of N1
> int main()
> {
>    int a[3] =3D { 1, 2, 3 };
>    std::forward_list<int> f( std::begin( a ), std::end( a ) );
>    std::list<int> l( std::begin( a ), std::end( a ) );
>    std::vector<int> v( std::begin( a ), std::end( a ) );
> =20
>    std::cout << "a:\t";
>    for ( int x : a ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "f:\t";
>    for ( int x : f ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "l:\t";
>    for ( int x : l ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "v:\t";
>    for ( int x : v ) std::cout << x << ' ';
>    std::cout << std::endl;
> =20
>    N1::reverse( a );
>    N1::reverse( f );
>    N1::reverse( l );
>    N1::reverse( v );
> =20
>    std::cout << "a:\t";
>    for ( int x : a ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "f:\t";
>    for ( int x : f ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "l:\t";
>    for ( int x : l ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "v:\t";
>    for ( int x : v ) std::cout << x << ' ';
>    std::cout << std::endl;
> =20
>    N1::sort( a );
>    N1::sort( f );
>    N1::sort( l );
>    N1::sort( v );
> =20
>    std::cout << "a:\t";
>    for ( int x : a ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "f:\t";
>    for ( int x : f ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "l:\t";
>    for ( int x : l ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "v:\t";
>    for ( int x : v ) std::cout << x << ' ';
>    std::cout << std::endl;
> =20
>    N1::sort( a, std::greater<int>() );
>    N1::sort( f, std::greater<int>() );
>    N1::sort( l, std::greater<int>() );
>    N1::sort( v, std::greater<int>() );
> =20
>    std::cout << "a:\t";
>    for ( int x : a ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "f:\t";
>    for ( int x : f ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "l:\t";
>    for ( int x : l ) std::cout << x << ' ';
>    std::cout << std::endl;
>    std::cout << "v:\t";
>    for ( int x : v ) std::cout << x << ' ';
>    std::cout << std::endl;
> }
> [/code]
> =20
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/126acf7d-4224-4a72-a34d-890d23ce5759%40isocpp.or=
g.

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

<div dir=3D"ltr">I&#39;m sorry.<div><br></div><div>It would be more correct=
ly to define the function the following way changing the return type tas it=
 is shown</div><div class=3D"prettyprint" style=3D"background-color: rgb(25=
0, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border=
-width: 1px; overflow-wrap: break-word;"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Container</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Container</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> sort</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Container</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">container=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> requires requires=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #606;" clas=
s=3D"styled-by-prettify">Container</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">sort</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 container</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">sort</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> container</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 <br></span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">template</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Container</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> <br></span><span style=3D"color: #606;" class=3D"styled-by-pretti=
fy">Container</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> sort</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">Container</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">container </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> <br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> <br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">sort</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">begin</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> container </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">end</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> container </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 <br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 container</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></div></c=
ode></div><div><br>Consider for example this question of a beginner as me a=
t Stackoverflow=C2=A0<a href=3D"https://stackoverflow.com/questions/5355788=
1/checking-if-two-strings-are-anagram#">https://stackoverflow.com/questions=
/53557881/checking-if-two-strings-are-anagram#</a></div><div><br></div><div=
>It is required to determine whether two strings are anagrams of each other=
..</div><div><br></div><div>One of approaches is to sort the strings and com=
pare them.</div><div><br></div><div>Using the functions above the function =
that determines whether strings are anagrams can be written easy.</div><div=
><br></div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 2=
50, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wid=
th: 1px; overflow-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">#include</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;iost=
ream&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #800;" class=3D"styled-by-prettify">#include=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify">&lt;iomanip&gt;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">#include</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;string&gt;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&lt;iterator&gt;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> <br></span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">#include</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" c=
lass=3D"styled-by-prettify">&lt;algorithm&gt;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> <br>=C2=A0 <br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">template</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Container</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> <br></span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Container</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> sort</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #606;" class=3D"styled-by-prettify">Container</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">container </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> requires requires</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">Container</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">sort</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> <br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> <br>=C2=A0 =C2=A0 container</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">sort</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> container</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <b=
r>=C2=A0 <br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">template</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">Container</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> <br></span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Container</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> sort</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Container</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">container </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> <br>=C2=A0 =C2=A0 std</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">sort</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">begin</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
container </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">end</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> container </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> <br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> container</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> isAnagrams</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">string</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> s1</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">string</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> s2 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">size</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> s1 </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">size</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> s2 </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">and</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> sort</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> s1 </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> sort</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> s2 </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br><br></span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> main</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #080;" class=3D"styled-by-prettify">&quot;Enter two stri=
ngs: &quot;</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 <br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">string</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> s1</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> s2<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <b=
r>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>cin </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> s1 </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;&gt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> s2</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =
=C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">&quot;The strings &quot;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">quoted</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> s1 </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #080;" class=3D"styled-by-prettify">&quot; and &quot;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">quoted</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> s2 </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #08=
0;" class=3D"styled-by-prettify">&quot; are &quot;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> isAnagrams</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> s1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> s2 </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">?</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"=
styled-by-prettify">&quot;&quot;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&qu=
ot;not&quot;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"st=
yled-by-prettify">&quot; anagrams of each other.\n&quot;</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span></div></code></div><div><br>Its outp=
ut might look like</div><div><br></div><div class=3D"prettyprint" style=3D"=
background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bor=
der-style: solid; border-width: 1px; overflow-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #606;=
" class=3D"styled-by-prettify">Enter</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> two strings</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> act tac<br></span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">The</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> strings </span><span style=3D"color: #080;" class=3D"styled-=
by-prettify">&quot;act&quot;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">and</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;t=
ac&quot;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a=
re anagrams of each other</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br><br><br></span></div></code></div><div><br><br></div><div><br><br=
>=D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F 20=
13 =D0=B3., 1:05:40 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=
=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div>In most cases s=
tandard algorithms (and some containers&#39; member functions) std::sort an=
d std:;reverse are called over a whole container. For example</div><div>=C2=
=A0</div><div>[code]</div><div>std::forward_list&lt;int&gt; f;</div><div>//=
 filling the list</div><div>f.sort();</div><div>// or</div><div>f.sort( std=
::greater&lt;int&gt;() );</div><div>=C2=A0</div><div>std::vector&lt;int&gt;=
 =C2=A0v;</div><div>//filling the vector</div><div>std::sort( v.begin(), v.=
end() );</div><div>// or</div><div>std::sort( v.begin(), v.end(), std::grea=
ter&lt;int&gt;() );</div><div>[/code]</div><div>=C2=A0</div><div>So I sugge=
st to introduce general functions std::reverse and std::sort that will=C2=
=A0accept=C2=A0 the reference to a container.</div><div>=C2=A0</div><div>Be=
low a demostrative example that illustrates the proposal</div><div>=C2=A0</=
div><div>[code]</div><div>#include &lt;iostream&gt;</div><div>#include &lt;=
algorithm&gt;</div><div>#include &lt;iterator&gt;</div><div>#include &lt;fu=
nctional&gt;</div><div>#include &lt;vector&gt;</div><div>#include &lt;forwa=
rd_list&gt;</div><div>#include &lt;list&gt;</div><div>=C2=A0</div><div>name=
space N1 // std</div><div>{</div><div>=C2=A0</div><div>template &lt;typenam=
e T&gt;<br>void reverse( T &amp;c )<br>{<br>=C2=A0std::reverse( std::begin(=
 c ), std::end( c ) );<br>}</div><div>=C2=A0</div><div>template &lt;typenam=
e T, typename Allocator&gt;<br>void reverse( std::forward_list&lt;T, Alloca=
tor&gt; &amp;f )<br>{<br>=C2=A0=C2=A0 f.reverse();<br>}</div><div>=C2=A0</d=
iv><div><div>template &lt;typename T, typename Allocator&gt;<br>void revers=
e( std::list&lt;T, Allocator&gt; &amp;l )<br>{<br>  =C2=A0=C2=A0=C2=A0 l.re=
verse();<br>}</div><div> </div></div><div>template &lt;typename T&gt;<br>vo=
id sort( T &amp;c )<br>{<br>=C2=A0=C2=A0 std::sort( std::begin( c ), std::e=
nd( c ) );<br>}</div><div>=C2=A0</div><div>template &lt;typename T, typenam=
e Allocator&gt;<br>void sort( std::forward_list&lt;T, Allocator&gt; &amp;f =
)<br>{<br>=C2=A0=C2=A0 f.sort();<br>}</div><div>=C2=A0</div><div><div>templ=
ate &lt;typename T, typename Allocator&gt;<br>void sort( std::list&lt;T, Al=
locator&gt; &amp;l )<br>{<br>=C2=A0=C2=A0=C2=A0l.sort();<br>}</div><div> </=
div></div><div>template &lt;typename T, typename Compare&gt;<br>void sort( =
T &amp;c, Compare comp )<br>{<br>=C2=A0=C2=A0 std::sort( std::begin( c ), s=
td::end( c ), comp );<br>}</div><div>=C2=A0</div><div>template &lt;typename=
 T, typename Allocator, typename Compare&gt;<br>void sort( std::forward_lis=
t&lt;T, Allocator&gt; &amp;f, Compare comp )<br>{<br>=C2=A0=C2=A0 f.sort( c=
omp );<br>}</div><div>=C2=A0</div><div><div>template &lt;typename T, typena=
me Allocator, typename Compare&gt;<br>void sort( std::list&lt;T, Allocator&=
gt; &amp;l, Compare comp )<br>{<br>=C2=A0=C2=A0 l.sort( comp );<br>}</div><=
/div><div>}=C2=A0//=C2=A0end of N1<br></div><div>int main()</div><div>{<br>=
=C2=A0=C2=A0 int a[3] =3D { 1, 2, 3 };<br>=C2=A0=C2=A0 std::forward_list&lt=
;int&gt; f( std::begin( a ), std::end( a ) );<br>=C2=A0=C2=A0 std::list&lt;=
int&gt; l( std::begin( a ), std::end( a ) );<br>=C2=A0=C2=A0 std::vector&lt=
;int&gt; v( std::begin( a ), std::end( a ) );</div><div>=C2=A0</div><div>=
=C2=A0=C2=A0 std::cout &lt;&lt; &quot;a:\t&quot;;<br>=C2=A0=C2=A0 for=C2=A0=
( int x=C2=A0: a ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=
=A0 std::cout &lt;&lt; std::endl;<br>=C2=A0=C2=A0 std::cout &lt;&lt; &quot;=
f:\t&quot;;<br>=C2=A0=C2=A0 for=C2=A0( int x=C2=A0:=C2=A0f ) std::cout &lt;=
&lt; x &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<=
br>=C2=A0=C2=A0 std::cout &lt;&lt; &quot;l:\t&quot;;<br>  =C2=A0=C2=A0 for =
( int x :=C2=A0l ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=
=C2=A0 std::cout &lt;&lt; std::endl;<br>=C2=A0=C2=A0 std::cout &lt;&lt; &qu=
ot;v:\t&quot;;<br>=C2=A0=C2=A0 for=C2=A0( int x=C2=A0: v ) std::cout &lt;&l=
t; x &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0 std::cout &lt;&lt; std::endl;</d=
iv><div>=C2=A0</div><div>=C2=A0=C2=A0 N1::reverse( a );<br>=C2=A0=C2=A0 N1:=
:reverse(=C2=A0f );<br>=C2=A0=C2=A0 N1::reverse( l );<br>=C2=A0=C2=A0 N1::r=
everse( v );</div><div>=C2=A0</div><div><div>  =C2=A0=C2=A0 std::cout &lt;&=
lt; &quot;a:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x : a ) std::cout &lt;&lt=
; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<b=
r>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;f:\t&quot;;<br>  =C2=A0=C2=A0 for=
 ( int x : f ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0=
 std::cout &lt;&lt; std::endl;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;l=
:\t&quot;;<br>    =C2=A0=C2=A0 for ( int x : l ) std::cout &lt;&lt; x &lt;&=
lt; &#39; &#39;;<br>    =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>  =C2=
=A0=C2=A0 std::cout &lt;&lt; &quot;v:\t&quot;;<br>  =C2=A0=C2=A0 for ( int =
x : v ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::c=
out &lt;&lt; std::endl;</div><div>=C2=A0</div>=C2=A0=C2=A0=C2=A0N1::sort( a=
 );<br>=C2=A0=C2=A0 N1::sort(=C2=A0f );<br>=C2=A0=C2=A0 N1::sort( l );<br>=
=C2=A0=C2=A0 N1::sort( v );</div><div>=C2=A0</div><div>=C2=A0=C2=A0 std::co=
ut &lt;&lt; &quot;a:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x : a ) std::cout=
 &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std:=
:endl;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;f:\t&quot;;<br>  =C2=A0=
=C2=A0 for ( int x : f ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =
=C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>  =C2=A0=C2=A0 std::cout &lt;=
&lt; &quot;l:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x : l ) std::cout &lt;&l=
t; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<=
br>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;v:\t&quot;;<br>  =C2=A0=C2=A0 fo=
r ( int x : v ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=
=A0 std::cout &lt;&lt; std::endl;</div><div>=C2=A0</div><div>=C2=A0=C2=A0 N=
1::sort( a, std::greater&lt;int&gt;() );<br>=C2=A0=C2=A0 N1::sort( f, std::=
greater&lt;int&gt;() );<br>=C2=A0=C2=A0 N1::sort( l, std::greater&lt;int&gt=
;() );<br>=C2=A0=C2=A0 N1::sort( v, std::greater&lt;int&gt;() );</div><div>=
=C2=A0</div><div><div>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;a:\t&quot;;<b=
r>    =C2=A0=C2=A0 for ( int x : a ) std::cout &lt;&lt; x &lt;&lt; &#39; &#=
39;;<br>    =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>    =C2=A0=C2=A0 =
std::cout &lt;&lt; &quot;f:\t&quot;;<br>    =C2=A0=C2=A0 for ( int x : f ) =
std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>    =C2=A0=C2=A0 std::cout &l=
t;&lt; std::endl;<br>    =C2=A0=C2=A0 std::cout &lt;&lt; &quot;l:\t&quot;;<=
br>    =C2=A0=C2=A0 for ( int x : l ) std::cout &lt;&lt; x &lt;&lt; &#39; &=
#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>  =C2=A0=C2=A0 std=
::cout &lt;&lt; &quot;v:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x : v ) std::=
cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; =
std::endl;</div>}<br>[/code]</div><div>=C2=A0</div></blockquote></div></div=
>

<p></p>

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

------=_Part_3585_1081225702.1543592251796--

------=_Part_3584_1202523852.1543592251795--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Sat, 1 Dec 2018 17:36:14 +0000
Raw View
--00000000000012759d057bf95b24
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Vlad,

as Justin already said, Ranges already do all that and more. What you want
is already in C++20.

G

On Fri, Nov 30, 2018 at 3:37 PM 'Vlad from Moscow' via ISO C++ Standard -
Future Proposals <std-proposals@isocpp.org> wrote:

> I'm sorry.
>
> It would be more correctly to define the function the following way
> changing the return type tas it is shown
> template <typename Container>
> Container & sort( Container &container ) requires requires() { &Container
> ::sort; }
> {
>     container.sort();
>
>     return container;
> }
>
> template <typename Container>
> Container & sort( Container &container )
> {
>     std::sort( std::begin( container ), std::end( container ) );
>
>     return container;
> }
>
>
> Consider for example this question of a beginner as me at Stackoverflow
> https://stackoverflow.com/questions/53557881/checking-if-two-strings-are-=
anagram#
>
> It is required to determine whether two strings are anagrams of each othe=
r.
>
> One of approaches is to sort the strings and compare them.
>
> Using the functions above the function that determines whether strings ar=
e
> anagrams can be written easy.
>
> #include <iostream>
> #include <iomanip>
> #include <string>
> #include <iterator>
> #include <algorithm>
>
> template <typename Container>
> Container & sort( Container &container ) requires requires() { &Container
> ::sort; }
> {
>     container.sort();
>
>     return container;
> }
>
> template <typename Container>
> Container & sort( Container &container )
> {
>     std::sort( std::begin( container ), std::end( container ) );
>
>     return container;
> }
>
>
> bool isAnagrams( std::string s1, std::string s2 )
> {
>     return std::size( s1 ) =3D=3D std::size( s2 ) and sort( s1 ) =3D=3D s=
ort( s2
> );
> }
>
>
> int main()
> {
>     std::cout << "Enter two strings: ";
>
>     std::string s1, s2;
>
>     std::cin >> s1 >> s2;
>
>     std::cout << "The strings " << std::quoted( s1 )
>               << " and " << std::quoted( s2 )
>               << " are " << ( isAnagrams( s1, s2 ) ? "" : "not" )
>               << " anagrams of each other.\n";
> }
>
>
> Its output might look like
>
> Enter two strings: act tac
> The strings "act" and "tac" are anagrams of each other.
>
>
>
>
>
>
> =D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F 2=
013 =D0=B3., 1:05:40 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>> In most cases standard algorithms (and some containers' member functions=
)
>> std::sort and std:;reverse are called over a whole container. For exampl=
e
>>
>> [code]
>> std::forward_list<int> f;
>> // filling the list
>> f.sort();
>> // or
>> f.sort( std::greater<int>() );
>>
>> std::vector<int>  v;
>> //filling the vector
>> std::sort( v.begin(), v.end() );
>> // or
>> std::sort( v.begin(), v.end(), std::greater<int>() );
>> [/code]
>>
>> So I suggest to introduce general functions std::reverse and std::sort
>> that will accept  the reference to a container.
>>
>> Below a demostrative example that illustrates the proposal
>>
>> [code]
>> #include <iostream>
>> #include <algorithm>
>> #include <iterator>
>> #include <functional>
>> #include <vector>
>> #include <forward_list>
>> #include <list>
>>
>> namespace N1 // std
>> {
>>
>> template <typename T>
>> void reverse( T &c )
>> {
>>  std::reverse( std::begin( c ), std::end( c ) );
>> }
>>
>> template <typename T, typename Allocator>
>> void reverse( std::forward_list<T, Allocator> &f )
>> {
>>    f.reverse();
>> }
>>
>> template <typename T, typename Allocator>
>> void reverse( std::list<T, Allocator> &l )
>> {
>>     l.reverse();
>> }
>> template <typename T>
>> void sort( T &c )
>> {
>>    std::sort( std::begin( c ), std::end( c ) );
>> }
>>
>> template <typename T, typename Allocator>
>> void sort( std::forward_list<T, Allocator> &f )
>> {
>>    f.sort();
>> }
>>
>> template <typename T, typename Allocator>
>> void sort( std::list<T, Allocator> &l )
>> {
>>    l.sort();
>> }
>> template <typename T, typename Compare>
>> void sort( T &c, Compare comp )
>> {
>>    std::sort( std::begin( c ), std::end( c ), comp );
>> }
>>
>> template <typename T, typename Allocator, typename Compare>
>> void sort( std::forward_list<T, Allocator> &f, Compare comp )
>> {
>>    f.sort( comp );
>> }
>>
>> template <typename T, typename Allocator, typename Compare>
>> void sort( std::list<T, Allocator> &l, Compare comp )
>> {
>>    l.sort( comp );
>> }
>> } // end of N1
>> int main()
>> {
>>    int a[3] =3D { 1, 2, 3 };
>>    std::forward_list<int> f( std::begin( a ), std::end( a ) );
>>    std::list<int> l( std::begin( a ), std::end( a ) );
>>    std::vector<int> v( std::begin( a ), std::end( a ) );
>>
>>    std::cout << "a:\t";
>>    for ( int x : a ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "f:\t";
>>    for ( int x : f ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "l:\t";
>>    for ( int x : l ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "v:\t";
>>    for ( int x : v ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>
>>    N1::reverse( a );
>>    N1::reverse( f );
>>    N1::reverse( l );
>>    N1::reverse( v );
>>
>>    std::cout << "a:\t";
>>    for ( int x : a ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "f:\t";
>>    for ( int x : f ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "l:\t";
>>    for ( int x : l ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "v:\t";
>>    for ( int x : v ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>
>>    N1::sort( a );
>>    N1::sort( f );
>>    N1::sort( l );
>>    N1::sort( v );
>>
>>    std::cout << "a:\t";
>>    for ( int x : a ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "f:\t";
>>    for ( int x : f ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "l:\t";
>>    for ( int x : l ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "v:\t";
>>    for ( int x : v ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>
>>    N1::sort( a, std::greater<int>() );
>>    N1::sort( f, std::greater<int>() );
>>    N1::sort( l, std::greater<int>() );
>>    N1::sort( v, std::greater<int>() );
>>
>>    std::cout << "a:\t";
>>    for ( int x : a ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "f:\t";
>>    for ( int x : f ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "l:\t";
>>    for ( int x : l ) std::cout << x << ' ';
>>    std::cout << std::endl;
>>    std::cout << "v:\t";
>>    for ( int x : v ) std::cout << x << ' ';
>>    std::cout << std::endl;
>> }
>> [/code]
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/126acf7d-422=
4-4a72-a34d-890d23ce5759%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/126acf7d-42=
24-4a72-a34d-890d23ce5759%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAANG%3DkXQDbTKJpB1HvyhU7%2BDmZXOyNMpJ5MLoC%3DaL=
-w4cUYSTA%40mail.gmail.com.

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

<div dir=3D"ltr">Vlad,<div><br></div><div>as Justin already said, Ranges al=
ready do all that and more. What you want is already in C++20.</div><div><b=
r></div><div>G</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">O=
n Fri, Nov 30, 2018 at 3:37 PM &#39;Vlad from Moscow&#39; via ISO C++ Stand=
ard - Future Proposals &lt;<a href=3D"mailto:std-proposals@isocpp.org">std-=
proposals@isocpp.org</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr">I&#39;m sorry.<div><br></div><div>It would be more correc=
tly to define the function the following way changing the return type tas i=
t is shown</div><div class=3D"m_6410032312815845825prettyprint" style=3D"ba=
ckground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:=
solid;border-width:1px"><code class=3D"m_6410032312815845825prettyprint"><d=
iv class=3D"m_6410032312815845825subprettyprint"><span style=3D"color:#008"=
 class=3D"m_6410032312815845825styled-by-prettify">template</span><span sty=
le=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span=
><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettif=
y">&lt;</span><span style=3D"color:#008" class=3D"m_6410032312815845825styl=
ed-by-prettify">typename</span><span style=3D"color:#000" class=3D"m_641003=
2312815845825styled-by-prettify"> </span><span style=3D"color:#606" class=
=3D"m_6410032312815845825styled-by-prettify">Container</span><span style=3D=
"color:#660" class=3D"m_6410032312815845825styled-by-prettify">&gt;</span><=
span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"=
> <br></span><span style=3D"color:#606" class=3D"m_6410032312815845825style=
d-by-prettify">Container</span><span style=3D"color:#000" class=3D"m_641003=
2312815845825styled-by-prettify"> </span><span style=3D"color:#660" class=
=3D"m_6410032312815845825styled-by-prettify">&amp;</span><span style=3D"col=
or:#000" class=3D"m_6410032312815845825styled-by-prettify"> sort</span><spa=
n style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">(<=
/span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pr=
ettify"> </span><span style=3D"color:#606" class=3D"m_6410032312815845825st=
yled-by-prettify">Container</span><span style=3D"color:#000" class=3D"m_641=
0032312815845825styled-by-prettify"> </span><span style=3D"color:#660" clas=
s=3D"m_6410032312815845825styled-by-prettify">&amp;</span><span style=3D"co=
lor:#000" class=3D"m_6410032312815845825styled-by-prettify">container </spa=
n><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-pretti=
fy">)</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled=
-by-prettify"> requires requires</span><span style=3D"color:#660" class=3D"=
m_6410032312815845825styled-by-prettify">()</span><span style=3D"color:#000=
" class=3D"m_6410032312815845825styled-by-prettify"> </span><span style=3D"=
color:#660" class=3D"m_6410032312815845825styled-by-prettify">{</span><span=
 style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> </=
span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-pre=
ttify">&amp;</span><span style=3D"color:#606" class=3D"m_641003231281584582=
5styled-by-prettify">Container</span><span style=3D"color:#660" class=3D"m_=
6410032312815845825styled-by-prettify">::</span><span style=3D"color:#000" =
class=3D"m_6410032312815845825styled-by-prettify">sort</span><span style=3D=
"color:#660" class=3D"m_6410032312815845825styled-by-prettify">;</span><spa=
n style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> <=
/span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-pr=
ettify">}</span><span style=3D"color:#000" class=3D"m_6410032312815845825st=
yled-by-prettify"> <br></span><span style=3D"color:#660" class=3D"m_6410032=
312815845825styled-by-prettify">{</span><span style=3D"color:#000" class=3D=
"m_6410032312815845825styled-by-prettify"> <br>=C2=A0 =C2=A0 container</spa=
n><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-pretti=
fy">.</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled=
-by-prettify">sort</span><span style=3D"color:#660" class=3D"m_641003231281=
5845825styled-by-prettify">();</span><span style=3D"color:#000" class=3D"m_=
6410032312815845825styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 =
</span><span style=3D"color:#008" class=3D"m_6410032312815845825styled-by-p=
rettify">return</span><span style=3D"color:#000" class=3D"m_641003231281584=
5825styled-by-prettify"> container</span><span style=3D"color:#660" class=
=3D"m_6410032312815845825styled-by-prettify">;</span><span style=3D"color:#=
000" class=3D"m_6410032312815845825styled-by-prettify"><br></span><span sty=
le=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">}</span=
><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettif=
y"> <br>=C2=A0 <br></span><span style=3D"color:#008" class=3D"m_64100323128=
15845825styled-by-prettify">template</span><span style=3D"color:#000" class=
=3D"m_6410032312815845825styled-by-prettify"> </span><span style=3D"color:#=
660" class=3D"m_6410032312815845825styled-by-prettify">&lt;</span><span sty=
le=3D"color:#008" class=3D"m_6410032312815845825styled-by-prettify">typenam=
e</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-=
prettify"> </span><span style=3D"color:#606" class=3D"m_6410032312815845825=
styled-by-prettify">Container</span><span style=3D"color:#660" class=3D"m_6=
410032312815845825styled-by-prettify">&gt;</span><span style=3D"color:#000"=
 class=3D"m_6410032312815845825styled-by-prettify"> <br></span><span style=
=3D"color:#606" class=3D"m_6410032312815845825styled-by-prettify">Container=
</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-p=
rettify"> </span><span style=3D"color:#660" class=3D"m_6410032312815845825s=
tyled-by-prettify">&amp;</span><span style=3D"color:#000" class=3D"m_641003=
2312815845825styled-by-prettify"> sort</span><span style=3D"color:#660" cla=
ss=3D"m_6410032312815845825styled-by-prettify">(</span><span style=3D"color=
:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><span styl=
e=3D"color:#606" class=3D"m_6410032312815845825styled-by-prettify">Containe=
r</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-=
prettify"> </span><span style=3D"color:#660" class=3D"m_6410032312815845825=
styled-by-prettify">&amp;</span><span style=3D"color:#000" class=3D"m_64100=
32312815845825styled-by-prettify">container </span><span style=3D"color:#66=
0" class=3D"m_6410032312815845825styled-by-prettify">)</span><span style=3D=
"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> <br></span>=
<span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify=
">{</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-b=
y-prettify"> <br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660" class=
=3D"m_6410032312815845825styled-by-prettify">::</span><span style=3D"color:=
#000" class=3D"m_6410032312815845825styled-by-prettify">sort</span><span st=
yle=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">(</spa=
n><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pretti=
fy"> std</span><span style=3D"color:#660" class=3D"m_6410032312815845825sty=
led-by-prettify">::</span><span style=3D"color:#008" class=3D"m_64100323128=
15845825styled-by-prettify">begin</span><span style=3D"color:#660" class=3D=
"m_6410032312815845825styled-by-prettify">(</span><span style=3D"color:#000=
" class=3D"m_6410032312815845825styled-by-prettify"> container </span><span=
 style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">),<=
/span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pr=
ettify"> std</span><span style=3D"color:#660" class=3D"m_641003231281584582=
5styled-by-prettify">::</span><span style=3D"color:#008" class=3D"m_6410032=
312815845825styled-by-prettify">end</span><span style=3D"color:#660" class=
=3D"m_6410032312815845825styled-by-prettify">(</span><span style=3D"color:#=
000" class=3D"m_6410032312815845825styled-by-prettify"> container </span><s=
pan style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">=
)</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-=
prettify"> </span><span style=3D"color:#660" class=3D"m_6410032312815845825=
styled-by-prettify">);</span><span style=3D"color:#000" class=3D"m_64100323=
12815845825styled-by-prettify"> <br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span>=
<span style=3D"color:#008" class=3D"m_6410032312815845825styled-by-prettify=
">return</span><span style=3D"color:#000" class=3D"m_6410032312815845825sty=
led-by-prettify"> container</span><span style=3D"color:#660" class=3D"m_641=
0032312815845825styled-by-prettify">;</span><span style=3D"color:#000" clas=
s=3D"m_6410032312815845825styled-by-prettify"><br></span><span style=3D"col=
or:#660" class=3D"m_6410032312815845825styled-by-prettify">}</span><span st=
yle=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"><br><b=
r></span></div></code></div><div><br>Consider for example this question of =
a beginner as me at Stackoverflow=C2=A0<a href=3D"https://stackoverflow.com=
/questions/53557881/checking-if-two-strings-are-anagram#" target=3D"_blank"=
>https://stackoverflow.com/questions/53557881/checking-if-two-strings-are-a=
nagram#</a></div><div><br></div><div>It is required to determine whether tw=
o strings are anagrams of each other.</div><div><br></div><div>One of appro=
aches is to sort the strings and compare them.</div><div><br></div><div>Usi=
ng the functions above the function that determines whether strings are ana=
grams can be written easy.</div><div><br></div><div class=3D"m_641003231281=
5845825prettyprint" style=3D"background-color:rgb(250,250,250);border-color=
:rgb(187,187,187);border-style:solid;border-width:1px"><code class=3D"m_641=
0032312815845825prettyprint"><div class=3D"m_6410032312815845825subprettypr=
int"><span style=3D"color:#800" class=3D"m_6410032312815845825styled-by-pre=
ttify">#include</span><span style=3D"color:#000" class=3D"m_641003231281584=
5825styled-by-prettify"> </span><span style=3D"color:#080" class=3D"m_64100=
32312815845825styled-by-prettify">&lt;iostream&gt;</span><span style=3D"col=
or:#000" class=3D"m_6410032312815845825styled-by-prettify"><br></span><span=
 style=3D"color:#800" class=3D"m_6410032312815845825styled-by-prettify">#in=
clude</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled=
-by-prettify"> </span><span style=3D"color:#080" class=3D"m_641003231281584=
5825styled-by-prettify">&lt;iomanip&gt;</span><span style=3D"color:#000" cl=
ass=3D"m_6410032312815845825styled-by-prettify"> <br></span><span style=3D"=
color:#800" class=3D"m_6410032312815845825styled-by-prettify">#include</spa=
n><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pretti=
fy"> </span><span style=3D"color:#080" class=3D"m_6410032312815845825styled=
-by-prettify">&lt;string&gt;</span><span style=3D"color:#000" class=3D"m_64=
10032312815845825styled-by-prettify"> <br></span><span style=3D"color:#800"=
 class=3D"m_6410032312815845825styled-by-prettify">#include</span><span sty=
le=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span=
><span style=3D"color:#080" class=3D"m_6410032312815845825styled-by-prettif=
y">&lt;iterator&gt;</span><span style=3D"color:#000" class=3D"m_64100323128=
15845825styled-by-prettify"> <br></span><span style=3D"color:#800" class=3D=
"m_6410032312815845825styled-by-prettify">#include</span><span style=3D"col=
or:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><span st=
yle=3D"color:#080" class=3D"m_6410032312815845825styled-by-prettify">&lt;al=
gorithm&gt;</span><span style=3D"color:#000" class=3D"m_6410032312815845825=
styled-by-prettify"> <br>=C2=A0 <br></span><span style=3D"color:#008" class=
=3D"m_6410032312815845825styled-by-prettify">template</span><span style=3D"=
color:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><span=
 style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">&lt=
;</span><span style=3D"color:#008" class=3D"m_6410032312815845825styled-by-=
prettify">typename</span><span style=3D"color:#000" class=3D"m_641003231281=
5845825styled-by-prettify"> </span><span style=3D"color:#606" class=3D"m_64=
10032312815845825styled-by-prettify">Container</span><span style=3D"color:#=
660" class=3D"m_6410032312815845825styled-by-prettify">&gt;</span><span sty=
le=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> <br></=
span><span style=3D"color:#606" class=3D"m_6410032312815845825styled-by-pre=
ttify">Container</span><span style=3D"color:#000" class=3D"m_64100323128158=
45825styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_6410=
032312815845825styled-by-prettify">&amp;</span><span style=3D"color:#000" c=
lass=3D"m_6410032312815845825styled-by-prettify"> sort</span><span style=3D=
"color:#660" class=3D"m_6410032312815845825styled-by-prettify">(</span><spa=
n style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> <=
/span><span style=3D"color:#606" class=3D"m_6410032312815845825styled-by-pr=
ettify">Container</span><span style=3D"color:#000" class=3D"m_6410032312815=
845825styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_641=
0032312815845825styled-by-prettify">&amp;</span><span style=3D"color:#000" =
class=3D"m_6410032312815845825styled-by-prettify">container </span><span st=
yle=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">)</spa=
n><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pretti=
fy"> requires requires</span><span style=3D"color:#660" class=3D"m_64100323=
12815845825styled-by-prettify">()</span><span style=3D"color:#000" class=3D=
"m_6410032312815845825styled-by-prettify"> </span><span style=3D"color:#660=
" class=3D"m_6410032312815845825styled-by-prettify">{</span><span style=3D"=
color:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><span=
 style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">&am=
p;</span><span style=3D"color:#606" class=3D"m_6410032312815845825styled-by=
-prettify">Container</span><span style=3D"color:#660" class=3D"m_6410032312=
815845825styled-by-prettify">::</span><span style=3D"color:#000" class=3D"m=
_6410032312815845825styled-by-prettify">sort</span><span style=3D"color:#66=
0" class=3D"m_6410032312815845825styled-by-prettify">;</span><span style=3D=
"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><spa=
n style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">}<=
/span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pr=
ettify"> <br></span><span style=3D"color:#660" class=3D"m_64100323128158458=
25styled-by-prettify">{</span><span style=3D"color:#000" class=3D"m_6410032=
312815845825styled-by-prettify"> <br>=C2=A0 =C2=A0 container</span><span st=
yle=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">.</spa=
n><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pretti=
fy">sort</span><span style=3D"color:#660" class=3D"m_6410032312815845825sty=
led-by-prettify">();</span><span style=3D"color:#000" class=3D"m_6410032312=
815845825styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color:#008" class=3D"m_6410032312815845825styled-by-prettify">r=
eturn</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled=
-by-prettify"> container</span><span style=3D"color:#660" class=3D"m_641003=
2312815845825styled-by-prettify">;</span><span style=3D"color:#000" class=
=3D"m_6410032312815845825styled-by-prettify"><br></span><span style=3D"colo=
r:#660" class=3D"m_6410032312815845825styled-by-prettify">}</span><span sty=
le=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> <br>=
=C2=A0 <br></span><span style=3D"color:#008" class=3D"m_6410032312815845825=
styled-by-prettify">template</span><span style=3D"color:#000" class=3D"m_64=
10032312815845825styled-by-prettify"> </span><span style=3D"color:#660" cla=
ss=3D"m_6410032312815845825styled-by-prettify">&lt;</span><span style=3D"co=
lor:#008" class=3D"m_6410032312815845825styled-by-prettify">typename</span>=
<span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify=
"> </span><span style=3D"color:#606" class=3D"m_6410032312815845825styled-b=
y-prettify">Container</span><span style=3D"color:#660" class=3D"m_641003231=
2815845825styled-by-prettify">&gt;</span><span style=3D"color:#000" class=
=3D"m_6410032312815845825styled-by-prettify"> <br></span><span style=3D"col=
or:#606" class=3D"m_6410032312815845825styled-by-prettify">Container</span>=
<span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify=
"> </span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-b=
y-prettify">&amp;</span><span style=3D"color:#000" class=3D"m_6410032312815=
845825styled-by-prettify"> sort</span><span style=3D"color:#660" class=3D"m=
_6410032312815845825styled-by-prettify">(</span><span style=3D"color:#000" =
class=3D"m_6410032312815845825styled-by-prettify"> </span><span style=3D"co=
lor:#606" class=3D"m_6410032312815845825styled-by-prettify">Container</span=
><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettif=
y"> </span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-=
by-prettify">&amp;</span><span style=3D"color:#000" class=3D"m_641003231281=
5845825styled-by-prettify">container </span><span style=3D"color:#660" clas=
s=3D"m_6410032312815845825styled-by-prettify">)</span><span style=3D"color:=
#000" class=3D"m_6410032312815845825styled-by-prettify"> <br></span><span s=
tyle=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">{</sp=
an><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prett=
ify"> <br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660" class=3D"m_641=
0032312815845825styled-by-prettify">::</span><span style=3D"color:#000" cla=
ss=3D"m_6410032312815845825styled-by-prettify">sort</span><span style=3D"co=
lor:#660" class=3D"m_6410032312815845825styled-by-prettify">(</span><span s=
tyle=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> std<=
/span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-pr=
ettify">::</span><span style=3D"color:#008" class=3D"m_6410032312815845825s=
tyled-by-prettify">begin</span><span style=3D"color:#660" class=3D"m_641003=
2312815845825styled-by-prettify">(</span><span style=3D"color:#000" class=
=3D"m_6410032312815845825styled-by-prettify"> container </span><span style=
=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">),</span>=
<span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify=
"> std</span><span style=3D"color:#660" class=3D"m_6410032312815845825style=
d-by-prettify">::</span><span style=3D"color:#008" class=3D"m_6410032312815=
845825styled-by-prettify">end</span><span style=3D"color:#660" class=3D"m_6=
410032312815845825styled-by-prettify">(</span><span style=3D"color:#000" cl=
ass=3D"m_6410032312815845825styled-by-prettify"> container </span><span sty=
le=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">)</span=
><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettif=
y"> </span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-=
by-prettify">);</span><span style=3D"color:#000" class=3D"m_641003231281584=
5825styled-by-prettify"> <br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color:#008" class=3D"m_6410032312815845825styled-by-prettify">retur=
n</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-=
prettify"> container</span><span style=3D"color:#660" class=3D"m_6410032312=
815845825styled-by-prettify">;</span><span style=3D"color:#000" class=3D"m_=
6410032312815845825styled-by-prettify"><br></span><span style=3D"color:#660=
" class=3D"m_6410032312815845825styled-by-prettify">}</span><span style=3D"=
color:#000" class=3D"m_6410032312815845825styled-by-prettify"><br><br><br><=
/span><span style=3D"color:#008" class=3D"m_6410032312815845825styled-by-pr=
ettify">bool</span><span style=3D"color:#000" class=3D"m_641003231281584582=
5styled-by-prettify"> isAnagrams</span><span style=3D"color:#660" class=3D"=
m_6410032312815845825styled-by-prettify">(</span><span style=3D"color:#000"=
 class=3D"m_6410032312815845825styled-by-prettify"> std</span><span style=
=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">::</span>=
<span style=3D"color:#008" class=3D"m_6410032312815845825styled-by-prettify=
">string</span><span style=3D"color:#000" class=3D"m_6410032312815845825sty=
led-by-prettify"> s1</span><span style=3D"color:#660" class=3D"m_6410032312=
815845825styled-by-prettify">,</span><span style=3D"color:#000" class=3D"m_=
6410032312815845825styled-by-prettify"> std</span><span style=3D"color:#660=
" class=3D"m_6410032312815845825styled-by-prettify">::</span><span style=3D=
"color:#008" class=3D"m_6410032312815845825styled-by-prettify">string</span=
><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettif=
y"> s2 </span><span style=3D"color:#660" class=3D"m_6410032312815845825styl=
ed-by-prettify">)</span><span style=3D"color:#000" class=3D"m_6410032312815=
845825styled-by-prettify"><br></span><span style=3D"color:#660" class=3D"m_=
6410032312815845825styled-by-prettify">{</span><span style=3D"color:#000" c=
lass=3D"m_6410032312815845825styled-by-prettify"><br>=C2=A0 =C2=A0 </span><=
span style=3D"color:#008" class=3D"m_6410032312815845825styled-by-prettify"=
>return</span><span style=3D"color:#000" class=3D"m_6410032312815845825styl=
ed-by-prettify"> std</span><span style=3D"color:#660" class=3D"m_6410032312=
815845825styled-by-prettify">::</span><span style=3D"color:#000" class=3D"m=
_6410032312815845825styled-by-prettify">size</span><span style=3D"color:#66=
0" class=3D"m_6410032312815845825styled-by-prettify">(</span><span style=3D=
"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> s1 </span><=
span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify"=
>)</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by=
-prettify"> </span><span style=3D"color:#660" class=3D"m_641003231281584582=
5styled-by-prettify">=3D=3D</span><span style=3D"color:#000" class=3D"m_641=
0032312815845825styled-by-prettify"> std</span><span style=3D"color:#660" c=
lass=3D"m_6410032312815845825styled-by-prettify">::</span><span style=3D"co=
lor:#000" class=3D"m_6410032312815845825styled-by-prettify">size</span><spa=
n style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">(<=
/span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pr=
ettify"> s2 </span><span style=3D"color:#660" class=3D"m_641003231281584582=
5styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_64100323=
12815845825styled-by-prettify"> </span><span style=3D"color:#008" class=3D"=
m_6410032312815845825styled-by-prettify">and</span><span style=3D"color:#00=
0" class=3D"m_6410032312815845825styled-by-prettify"> sort</span><span styl=
e=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">(</span>=
<span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify=
"> s1 </span><span style=3D"color:#660" class=3D"m_6410032312815845825style=
d-by-prettify">)</span><span style=3D"color:#000" class=3D"m_64100323128158=
45825styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_6410=
032312815845825styled-by-prettify">=3D=3D</span><span style=3D"color:#000" =
class=3D"m_6410032312815845825styled-by-prettify"> sort</span><span style=
=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">(</span><=
span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"=
> s2 </span><span style=3D"color:#660" class=3D"m_6410032312815845825styled=
-by-prettify">);</span><span style=3D"color:#000" class=3D"m_64100323128158=
45825styled-by-prettify"><br></span><span style=3D"color:#660" class=3D"m_6=
410032312815845825styled-by-prettify">}</span><span style=3D"color:#000" cl=
ass=3D"m_6410032312815845825styled-by-prettify"><br><br><br></span><span st=
yle=3D"color:#008" class=3D"m_6410032312815845825styled-by-prettify">int</s=
pan><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pret=
tify"> main</span><span style=3D"color:#660" class=3D"m_6410032312815845825=
styled-by-prettify">()</span><span style=3D"color:#000" class=3D"m_64100323=
12815845825styled-by-prettify"><br></span><span style=3D"color:#660" class=
=3D"m_6410032312815845825styled-by-prettify">{</span><span style=3D"color:#=
000" class=3D"m_6410032312815845825styled-by-prettify"><br>=C2=A0 =C2=A0 st=
d</span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-=
prettify">::</span><span style=3D"color:#000" class=3D"m_641003231281584582=
5styled-by-prettify">cout </span><span style=3D"color:#660" class=3D"m_6410=
032312815845825styled-by-prettify">&lt;&lt;</span><span style=3D"color:#000=
" class=3D"m_6410032312815845825styled-by-prettify"> </span><span style=3D"=
color:#080" class=3D"m_6410032312815845825styled-by-prettify">&quot;Enter t=
wo strings: &quot;</span><span style=3D"color:#660" class=3D"m_641003231281=
5845825styled-by-prettify">;</span><span style=3D"color:#000" class=3D"m_64=
10032312815845825styled-by-prettify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 st=
d</span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-=
prettify">::</span><span style=3D"color:#008" class=3D"m_641003231281584582=
5styled-by-prettify">string</span><span style=3D"color:#000" class=3D"m_641=
0032312815845825styled-by-prettify"> s1</span><span style=3D"color:#660" cl=
ass=3D"m_6410032312815845825styled-by-prettify">,</span><span style=3D"colo=
r:#000" class=3D"m_6410032312815845825styled-by-prettify"> s2</span><span s=
tyle=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">;</sp=
an><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prett=
ify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 std</span><span style=3D"color:#66=
0" class=3D"m_6410032312815845825styled-by-prettify">::</span><span style=
=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify">cin </spa=
n><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-pretti=
fy">&gt;&gt;</span><span style=3D"color:#000" class=3D"m_641003231281584582=
5styled-by-prettify"> s1 </span><span style=3D"color:#660" class=3D"m_64100=
32312815845825styled-by-prettify">&gt;&gt;</span><span style=3D"color:#000"=
 class=3D"m_6410032312815845825styled-by-prettify"> s2</span><span style=3D=
"color:#660" class=3D"m_6410032312815845825styled-by-prettify">;</span><spa=
n style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"><b=
r>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660" clas=
s=3D"m_6410032312815845825styled-by-prettify">::</span><span style=3D"color=
:#000" class=3D"m_6410032312815845825styled-by-prettify">cout </span><span =
style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">&lt;=
&lt;</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-=
by-prettify"> </span><span style=3D"color:#080" class=3D"m_6410032312815845=
825styled-by-prettify">&quot;The strings &quot;</span><span style=3D"color:=
#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><span style=
=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">&lt;&lt;<=
/span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pr=
ettify"> std</span><span style=3D"color:#660" class=3D"m_641003231281584582=
5styled-by-prettify">::</span><span style=3D"color:#000" class=3D"m_6410032=
312815845825styled-by-prettify">quoted</span><span style=3D"color:#660" cla=
ss=3D"m_6410032312815845825styled-by-prettify">(</span><span style=3D"color=
:#000" class=3D"m_6410032312815845825styled-by-prettify"> s1 </span><span s=
tyle=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">)</sp=
an><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prett=
ify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span styl=
e=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">&lt;&lt;=
</span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-p=
rettify"> </span><span style=3D"color:#080" class=3D"m_6410032312815845825s=
tyled-by-prettify">&quot; and &quot;</span><span style=3D"color:#000" class=
=3D"m_6410032312815845825styled-by-prettify"> </span><span style=3D"color:#=
660" class=3D"m_6410032312815845825styled-by-prettify">&lt;&lt;</span><span=
 style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> st=
d</span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-by-=
prettify">::</span><span style=3D"color:#000" class=3D"m_641003231281584582=
5styled-by-prettify">quoted</span><span style=3D"color:#660" class=3D"m_641=
0032312815845825styled-by-prettify">(</span><span style=3D"color:#000" clas=
s=3D"m_6410032312815845825styled-by-prettify"> s2 </span><span style=3D"col=
or:#660" class=3D"m_6410032312815845825styled-by-prettify">)</span><span st=
yle=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> <br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"colo=
r:#660" class=3D"m_6410032312815845825styled-by-prettify">&lt;&lt;</span><s=
pan style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify">=
 </span><span style=3D"color:#080" class=3D"m_6410032312815845825styled-by-=
prettify">&quot; are &quot;</span><span style=3D"color:#000" class=3D"m_641=
0032312815845825styled-by-prettify"> </span><span style=3D"color:#660" clas=
s=3D"m_6410032312815845825styled-by-prettify">&lt;&lt;</span><span style=3D=
"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><spa=
n style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">(<=
/span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pr=
ettify"> isAnagrams</span><span style=3D"color:#660" class=3D"m_64100323128=
15845825styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_6=
410032312815845825styled-by-prettify"> s1</span><span style=3D"color:#660" =
class=3D"m_6410032312815845825styled-by-prettify">,</span><span style=3D"co=
lor:#000" class=3D"m_6410032312815845825styled-by-prettify"> s2 </span><spa=
n style=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">)<=
/span><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pr=
ettify"> </span><span style=3D"color:#660" class=3D"m_6410032312815845825st=
yled-by-prettify">?</span><span style=3D"color:#000" class=3D"m_64100323128=
15845825styled-by-prettify"> </span><span style=3D"color:#080" class=3D"m_6=
410032312815845825styled-by-prettify">&quot;&quot;</span><span style=3D"col=
or:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><span st=
yle=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">:</spa=
n><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-pretti=
fy"> </span><span style=3D"color:#080" class=3D"m_6410032312815845825styled=
-by-prettify">&quot;not&quot;</span><span style=3D"color:#000" class=3D"m_6=
410032312815845825styled-by-prettify"> </span><span style=3D"color:#660" cl=
ass=3D"m_6410032312815845825styled-by-prettify">)</span><span style=3D"colo=
r:#000" class=3D"m_6410032312815845825styled-by-prettify"><br>=C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#660" class=
=3D"m_6410032312815845825styled-by-prettify">&lt;&lt;</span><span style=3D"=
color:#000" class=3D"m_6410032312815845825styled-by-prettify"> </span><span=
 style=3D"color:#080" class=3D"m_6410032312815845825styled-by-prettify">&qu=
ot; anagrams of each other.\n&quot;</span><span style=3D"color:#660" class=
=3D"m_6410032312815845825styled-by-prettify">;</span><span style=3D"color:#=
000" class=3D"m_6410032312815845825styled-by-prettify"><br></span><span sty=
le=3D"color:#660" class=3D"m_6410032312815845825styled-by-prettify">}</span=
><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettif=
y"><br><br></span></div></code></div><div><br>Its output might look like</d=
iv><div><br></div><div class=3D"m_6410032312815845825prettyprint" style=3D"=
background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-styl=
e:solid;border-width:1px"><code class=3D"m_6410032312815845825prettyprint">=
<div class=3D"m_6410032312815845825subprettyprint"><span style=3D"color:#60=
6" class=3D"m_6410032312815845825styled-by-prettify">Enter</span><span styl=
e=3D"color:#000" class=3D"m_6410032312815845825styled-by-prettify"> two str=
ings</span><span style=3D"color:#660" class=3D"m_6410032312815845825styled-=
by-prettify">:</span><span style=3D"color:#000" class=3D"m_6410032312815845=
825styled-by-prettify"> act tac<br></span><span style=3D"color:#606" class=
=3D"m_6410032312815845825styled-by-prettify">The</span><span style=3D"color=
:#000" class=3D"m_6410032312815845825styled-by-prettify"> strings </span><s=
pan style=3D"color:#080" class=3D"m_6410032312815845825styled-by-prettify">=
&quot;act&quot;</span><span style=3D"color:#000" class=3D"m_641003231281584=
5825styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_64100=
32312815845825styled-by-prettify">and</span><span style=3D"color:#000" clas=
s=3D"m_6410032312815845825styled-by-prettify"> </span><span style=3D"color:=
#080" class=3D"m_6410032312815845825styled-by-prettify">&quot;tac&quot;</sp=
an><span style=3D"color:#000" class=3D"m_6410032312815845825styled-by-prett=
ify"> are anagrams of each other</span><span style=3D"color:#660" class=3D"=
m_6410032312815845825styled-by-prettify">.</span><span style=3D"color:#000"=
 class=3D"m_6410032312815845825styled-by-prettify"><br><br><br></span></div=
></code></div><div><br><br></div><div><br><br>=D0=B2=D1=82=D0=BE=D1=80=D0=
=BD=D0=B8=D0=BA, 25 =D0=B8=D1=8E=D0=BD=D1=8F 2013 =D0=B3., 1:05:40 UTC+4 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vl=
ad from Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div>In most cases standard algorithms (and some con=
tainers&#39; member functions) std::sort and std:;reverse are called over a=
 whole container. For example</div><div>=C2=A0</div><div>[code]</div><div>s=
td::forward_list&lt;int&gt; f;</div><div>// filling the list</div><div>f.so=
rt();</div><div>// or</div><div>f.sort( std::greater&lt;int&gt;() );</div><=
div>=C2=A0</div><div>std::vector&lt;int&gt; =C2=A0v;</div><div>//filling th=
e vector</div><div>std::sort( v.begin(), v.end() );</div><div>// or</div><d=
iv>std::sort( v.begin(), v.end(), std::greater&lt;int&gt;() );</div><div>[/=
code]</div><div>=C2=A0</div><div>So I suggest to introduce general function=
s std::reverse and std::sort that will=C2=A0accept=C2=A0 the reference to a=
 container.</div><div>=C2=A0</div><div>Below a demostrative example that il=
lustrates the proposal</div><div>=C2=A0</div><div>[code]</div><div>#include=
 &lt;iostream&gt;</div><div>#include &lt;algorithm&gt;</div><div>#include &=
lt;iterator&gt;</div><div>#include &lt;functional&gt;</div><div>#include &l=
t;vector&gt;</div><div>#include &lt;forward_list&gt;</div><div>#include &lt=
;list&gt;</div><div>=C2=A0</div><div>namespace N1 // std</div><div>{</div><=
div>=C2=A0</div><div>template &lt;typename T&gt;<br>void reverse( T &amp;c =
)<br>{<br>=C2=A0std::reverse( std::begin( c ), std::end( c ) );<br>}</div><=
div>=C2=A0</div><div>template &lt;typename T, typename Allocator&gt;<br>voi=
d reverse( std::forward_list&lt;T, Allocator&gt; &amp;f )<br>{<br>=C2=A0=C2=
=A0 f.reverse();<br>}</div><div>=C2=A0</div><div><div>template &lt;typename=
 T, typename Allocator&gt;<br>void reverse( std::list&lt;T, Allocator&gt; &=
amp;l )<br>{<br>  =C2=A0=C2=A0=C2=A0 l.reverse();<br>}</div><div> </div></d=
iv><div>template &lt;typename T&gt;<br>void sort( T &amp;c )<br>{<br>=C2=A0=
=C2=A0 std::sort( std::begin( c ), std::end( c ) );<br>}</div><div>=C2=A0</=
div><div>template &lt;typename T, typename Allocator&gt;<br>void sort( std:=
:forward_list&lt;T, Allocator&gt; &amp;f )<br>{<br>=C2=A0=C2=A0 f.sort();<b=
r>}</div><div>=C2=A0</div><div><div>template &lt;typename T, typename Alloc=
ator&gt;<br>void sort( std::list&lt;T, Allocator&gt; &amp;l )<br>{<br>=C2=
=A0=C2=A0=C2=A0l.sort();<br>}</div><div> </div></div><div>template &lt;type=
name T, typename Compare&gt;<br>void sort( T &amp;c, Compare comp )<br>{<br=
>=C2=A0=C2=A0 std::sort( std::begin( c ), std::end( c ), comp );<br>}</div>=
<div>=C2=A0</div><div>template &lt;typename T, typename Allocator, typename=
 Compare&gt;<br>void sort( std::forward_list&lt;T, Allocator&gt; &amp;f, Co=
mpare comp )<br>{<br>=C2=A0=C2=A0 f.sort( comp );<br>}</div><div>=C2=A0</di=
v><div><div>template &lt;typename T, typename Allocator, typename Compare&g=
t;<br>void sort( std::list&lt;T, Allocator&gt; &amp;l, Compare comp )<br>{<=
br>=C2=A0=C2=A0 l.sort( comp );<br>}</div></div><div>}=C2=A0//=C2=A0end of =
N1<br></div><div>int main()</div><div>{<br>=C2=A0=C2=A0 int a[3] =3D { 1, 2=
, 3 };<br>=C2=A0=C2=A0 std::forward_list&lt;int&gt; f( std::begin( a ), std=
::end( a ) );<br>=C2=A0=C2=A0 std::list&lt;int&gt; l( std::begin( a ), std:=
:end( a ) );<br>=C2=A0=C2=A0 std::vector&lt;int&gt; v( std::begin( a ), std=
::end( a ) );</div><div>=C2=A0</div><div>=C2=A0=C2=A0 std::cout &lt;&lt; &q=
uot;a:\t&quot;;<br>=C2=A0=C2=A0 for=C2=A0( int x=C2=A0: a ) std::cout &lt;&=
lt; x &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<b=
r>=C2=A0=C2=A0 std::cout &lt;&lt; &quot;f:\t&quot;;<br>=C2=A0=C2=A0 for=C2=
=A0( int x=C2=A0:=C2=A0f ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>=
=C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>=C2=A0=C2=A0 std::cout &lt;&l=
t; &quot;l:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x :=C2=A0l ) std::cout &lt=
;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::end=
l;<br>=C2=A0=C2=A0 std::cout &lt;&lt; &quot;v:\t&quot;;<br>=C2=A0=C2=A0 for=
=C2=A0( int x=C2=A0: v ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>=C2=
=A0=C2=A0 std::cout &lt;&lt; std::endl;</div><div>=C2=A0</div><div>=C2=A0=
=C2=A0 N1::reverse( a );<br>=C2=A0=C2=A0 N1::reverse(=C2=A0f );<br>=C2=A0=
=C2=A0 N1::reverse( l );<br>=C2=A0=C2=A0 N1::reverse( v );</div><div>=C2=A0=
</div><div><div>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;a:\t&quot;;<br>  =
=C2=A0=C2=A0 for ( int x : a ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<b=
r>  =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>  =C2=A0=C2=A0 std::cout =
&lt;&lt; &quot;f:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x : f ) std::cout &l=
t;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::en=
dl;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;l:\t&quot;;<br>    =C2=A0=C2=
=A0 for ( int x : l ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>    =C2=
=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>  =C2=A0=C2=A0 std::cout &lt;&lt=
; &quot;v:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x : v ) std::cout &lt;&lt; =
x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;</di=
v><div>=C2=A0</div>=C2=A0=C2=A0=C2=A0N1::sort( a );<br>=C2=A0=C2=A0 N1::sor=
t(=C2=A0f );<br>=C2=A0=C2=A0 N1::sort( l );<br>=C2=A0=C2=A0 N1::sort( v );<=
/div><div>=C2=A0</div><div>=C2=A0=C2=A0 std::cout &lt;&lt; &quot;a:\t&quot;=
;<br>  =C2=A0=C2=A0 for ( int x : a ) std::cout &lt;&lt; x &lt;&lt; &#39; &=
#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>  =C2=A0=C2=A0 std=
::cout &lt;&lt; &quot;f:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x : f ) std::=
cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; =
std::endl;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;l:\t&quot;;<br>  =C2=
=A0=C2=A0 for ( int x : l ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br> =
 =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>  =C2=A0=C2=A0 std::cout &lt=
;&lt; &quot;v:\t&quot;;<br>  =C2=A0=C2=A0 for ( int x : v ) std::cout &lt;&=
lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;=
</div><div>=C2=A0</div><div>=C2=A0=C2=A0 N1::sort( a, std::greater&lt;int&g=
t;() );<br>=C2=A0=C2=A0 N1::sort( f, std::greater&lt;int&gt;() );<br>=C2=A0=
=C2=A0 N1::sort( l, std::greater&lt;int&gt;() );<br>=C2=A0=C2=A0 N1::sort( =
v, std::greater&lt;int&gt;() );</div><div>=C2=A0</div><div><div>  =C2=A0=C2=
=A0 std::cout &lt;&lt; &quot;a:\t&quot;;<br>    =C2=A0=C2=A0 for ( int x : =
a ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>    =C2=A0=C2=A0 std::cou=
t &lt;&lt; std::endl;<br>    =C2=A0=C2=A0 std::cout &lt;&lt; &quot;f:\t&quo=
t;;<br>    =C2=A0=C2=A0 for ( int x : f ) std::cout &lt;&lt; x &lt;&lt; &#3=
9; &#39;;<br>    =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>    =C2=A0=
=C2=A0 std::cout &lt;&lt; &quot;l:\t&quot;;<br>    =C2=A0=C2=A0 for ( int x=
 : l ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>  =C2=A0=C2=A0 std::co=
ut &lt;&lt; std::endl;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; &quot;v:\t&quot=
;;<br>  =C2=A0=C2=A0 for ( int x : v ) std::cout &lt;&lt; x &lt;&lt; &#39; =
&#39;;<br>  =C2=A0=C2=A0 std::cout &lt;&lt; std::endl;</div>}<br>[/code]</d=
iv><div>=C2=A0</div></blockquote></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/126acf7d-4224-4a72-a34d-890d23ce5759%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/126acf7d-4224-=
4a72-a34d-890d23ce5759%40isocpp.org</a>.<br>
</blockquote></div>

<p></p>

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

--00000000000012759d057bf95b24--

.