220 33199 <1E3763D6-C8A5-471A-AA44-F5CFDEDD6D9E@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Dan Raviv <dan.raviv@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: [idea for proposal] Adding std::shift to <algorithm>
Date: Thu, 13 Jul 2017 14:41:28 +0300
Lines: 335
Approved: news@gmane.org
Message-ID: <1E3763D6-C8A5-471A-AA44-F5CFDEDD6D9E@gmail.com>
References: <bd1a5d3b-ccc1-44ab-91cc-a4d7195c9dc3@isocpp.org> <68bbd6d3-1578-43e1-b15f-563c9d6fb27c@isocpp.org> <c722a201-5c9c-4ac5-a1bd-e50beb6d7860@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0 (1.0)
Content-Type: multipart/alternative;
	boundary=Apple-Mail-B758B76A-D759-4322-99A9-61165DC59A77
Content-Transfer-Encoding: 7bit
X-Trace: blaine.gmane.org 1499946093 23183 195.159.176.226 (13 Jul 2017 11:41:33 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 13 Jul 2017 11:41:33 +0000 (UTC)
Cc: dan@soundradix.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5YJREBWAGRB3FYTXFQKGQEVLKKVUQ@isocpp.org Thu Jul 13 13:41:28 2017
Return-path: <std-proposals+bncBC5YJREBWAGRB3FYTXFQKGQEVLKKVUQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f72.google.com ([74.125.82.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5YJREBWAGRB3FYTXFQKGQEVLKKVUQ@isocpp.org>)
	id 1dVcUq-0005kW-Dp
	for gclcip-std-proposals@m.gmane.org; Thu, 13 Jul 2017 13:41:28 +0200
Original-Received: by mail-wm0-f72.google.com with SMTP id b11sf3767257wmh.0
        for <gclcip-std-proposals@m.gmane.org>; Thu, 13 Jul 2017 04:41:34 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1499946093; cv=pass;
        d=google.com; s=arc-20160816;
        b=JyaFgw8urQMnZPfwNNi9uzNat/ibD+4mat3b+VypJ8uGZ/f69m9TbLJZWy5WaY07tR
         nF2klIN07L6jvE3hnk1AMpS4AFgAFyLBWsnen5abCtlJWppsduOR155sbAkvyhGwuERK
         9WMuxZHZf0IMiilRS7k/Jb1ueB1OiopnUiQKuX/ixBjndPlA+zDmAtN+czKzHPK9UlnK
         e2ybgQ0C6XH0OZRdB6KIXz5gCrIpv/10ZhNyE28xmHpcwU8hEbbZKGz8r4p4A3e+27ah
         7EqPHbK4C6nAq4iXUV5ueDWe3ur29UglOvQVf+vDxQYyQUPVf+d3nb4tAlcApsve89S8
         hClw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:references:message-id
         :content-transfer-encoding:cc:date:in-reply-to:from:subject
         :mime-version:arc-authentication-results:arc-message-signature
         :dkim-signature:arc-authentication-results;
        bh=m+lyPIvA+0709NmErGf30f+++wUhQI33EsZyjJVwDyE=;
        b=bq9SmXlq4vmTasJPBrmRVSi1Bt+KJ+YrVuXaZ8XJRA+A53clYwpa6zTtuKU7Vom069
         2r8PCu0T7Z2vtqF0UGIFeU+nB6iHqOArp2oPGxiKo4SofZNeYvPYeFVohp6iU/KC4eG8
         6q2EjSiwZ/jc77x7GLPskcZfdHUoahhb1ypOzITDq3lCHJG6QfiqsFsj8oU0O1RLi9Ve
         vGI5EfmgiQkkgUw0DhIzWHFJKlnbPNVPNHc6jS/Z6BYqukgxFl8JN9Y4RcaRbe1Gp0+e
         R3fqhh9aoJhuyqopvE9E94yIadurwtv1sTWAoXPjSIaW58UdqGTJ7+sg0OEoOZDZdv+4
         +Khw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=e69nZ+TF;
       spf=pass (google.com: domain of dan.raviv@gmail.com designates 2a00:1450:400c:c09::242 as permitted sender) smtp.mailfrom=dan.raviv@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:subject:from:in-reply-to:date:cc
         :content-transfer-encoding:message-id:references:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=m+lyPIvA+0709NmErGf30f+++wUhQI33EsZyjJVwDyE=;
        b=XlZITdrHigLT3ogKSKmdIa+bZt8yPrnK1UHDTcvHxTaRjo1ynl4Uer5NhDP+6Ad+u2
         bsWJQc/CmXCRSPX0ISR+8MvA1oHhd6+GRTyF8XMySYzaOdeuhZmY9sFTYKklltpUp55B
         7gsLi+ayi9nx2xSeBiFrw6DGkxts4/zuuIBgqe+E8mGn6P3+BQhCN1dyqOY1xYZk6mZW
         HA6JR62AH5HTkvcKxNw2UL8P+RKkNhTgsBKVrbgzetPyRA/Buv1bcKtjK/pPCFg3Pq4o
         k/bJMAg1iy1iLUuPAModHOlC4CQw/xLrpAIxyH7SCA4tcNTNNGKhtgchEhJNTkyOIcSC
         pjbQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc
         :content-transfer-encoding:message-id:references:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=m+lyPIvA+0709NmErGf30f+++wUhQI33EsZyjJVwDyE=;
        b=p3auuSuxArn3vL+urBG6kBDpq/RNK023Pp92dcfY/gsRl1sJLWD7JPvJbscEOu/IqJ
         6inSTqmVJ76ufuRVevP6lThMQ//zgw3BiIgNQgXdrA+ROFCT+c+TlaKztDdtsEt2z6JJ
         bAHOvWpghX8tthLOHjuQGpu7qiOwQV7qL3B2hWkIluNThMFtBAundw4/bc144hsciRE2
         2BMqRr1LcE0j2xS0p/fL4TCjhQhwohAdHVKj6w64c/qeDvovCpxlpb0TGo5iEf4qjPmf
         pZvF0/rulbnD0OfnCy0gdbqU3cIDnLf2Y1PZsRBfuwi1L8fquiaARWjqSr8tmYwrszWA
          
X-Gm-Message-State: AIVw110nHZD5qof/JQ0g06V5oaTVcaMKLco4cF3H33oDge54cTPNdTz0
	HfrzTBBKXtH3LE2R
X-Received: by 10.223.129.138 with SMTP id 10mr134750wra.12.1499946093699;
        Thu, 13 Jul 2017 04:41:33 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.87.213 with SMTP id l204ls762301wmb.15.gmail; Thu, 13 Jul
 2017 04:41:31 -0700 (PDT)
X-Received: by 10.223.132.133 with SMTP id 5mr1316749wrg.132.1499946091698;
        Thu, 13 Jul 2017 04:41:31 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1499946091; cv=none;
        d=google.com; s=arc-20160816;
        b=MJrbAsGVzlhNP5N47ZqgfBYCBD93tigrgydHRo6ncV+mNvtWpgLuACnE57PCiC4Dao
         fAuSOp1OzPG/awtp/0vT/sWUhtCGNYbeiHN4v45IvMGBmctc750Mm9GL+anxB0fw+U2x
         8IHm0CF+9dBApWc3eZw+HtMQLhM+VBmei7mkvdJcSg+oV/JdwkcMRBrVwuny8cZPz8XF
         6LLD+J2sUYK0qBEa8EfCONz/IcCa/tMX+d8BFiF6rZOEENZWuhY29cLeEpv6y6tHJqZ9
         E8T+Ju1ka5X3nxDFpokQ2NNu4XrhpvQ5aZ4GesBTeUOLYCG8UpQFFmmjv2IfDOQtaFvh
         jFpg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:references:message-id:content-transfer-encoding:cc:date
         :in-reply-to:from:subject:mime-version:dkim-signature
         :arc-authentication-results;
        bh=hZfoRHKfY1J/bHIAzL2LIHhUcfzsON0yVq8YBhISLUo=;
        b=TA9u4zSXOL4JbS3yeXseFbeE12vjK6FwOQLXPEjmOVio0Befg7R7t/A72TTy7dNpMT
         tRiaXLSyLGK8R6mxPTORFXV0rYIMWeNSv2NdPMi/ASyKwNzc6bfov0DxIhImXQHUjYhT
         iLMAglOzfN9hnuFCzHqKwJYM050jrCFFsi5halXos1UzW703sFyt5C7CUFyxC+SmVExU
         Tsf4RUANNhmg0PpLAadg4+jU+0IF8AHoI9iG0EnVVoqdIhZg1eHf8vxF9hkI9euBg8Un
         JxTH/cmiSKsNF0hkLPxpwv4WNZQX44mGcBRP5GCA98OSsYgOZwKAL0cpwvMInhHPC4uu
         zbfg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=e69nZ+TF;
       spf=pass (google.com: domain of dan.raviv@gmail.com designates 2a00:1450:400c:c09::242 as permitted sender) smtp.mailfrom=dan.raviv@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com. [2a00:1450:400c:c09::242])
        by mx.google.com with ESMTPS id z14si4048875wrb.48.2017.07.13.04.41.31
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 13 Jul 2017 04:41:31 -0700 (PDT)
Received-SPF: pass (google.com: domain of dan.raviv@gmail.com designates 2a00:1450:400c:c09::242 as permitted sender) client-ip=2a00:1450:400c:c09::242;
Original-Received: by mail-wm0-x242.google.com with SMTP id u23so4539461wma.2
        for <std-proposals@isocpp.org>; Thu, 13 Jul 2017 04:41:31 -0700 (PDT)
X-Received: by 10.28.88.8 with SMTP id m8mr1684868wmb.128.1499946091101;
        Thu, 13 Jul 2017 04:41:31 -0700 (PDT)
Original-Received: from [10.84.62.117] ([46.19.86.117])
        by smtp.gmail.com with ESMTPSA id r40sm5877860wrb.37.2017.07.13.04.41.29
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 13 Jul 2017 04:41:29 -0700 (PDT)
X-Mailer: iPhone Mail (14F89)
In-Reply-To: <c722a201-5c9c-4ac5-a1bd-e50beb6d7860@isocpp.org>
X-Original-Sender: dan.raviv@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.b=e69nZ+TF;       spf=pass (google.com: domain of
 dan.raviv@gmail.com designates 2a00:1450:400c:c09::242 as permitted sender)
 smtp.mailfrom=dan.raviv@gmail.com;       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:33199
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33199>


--Apple-Mail-B758B76A-D759-4322-99A9-61165DC59A77
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thanks for phrasing the motivation so well Nicol.

Arthur, regarding specific use cases, any algorithm doing time series analy=
sis (e.g. temperature the last 20 days) could use this.

(A cyclical buffer is an alternative, but one which isn't always preferrabl=
e.)

> On 13 Jul 2017, at 4:43, Nicol Bolas <jmckesson@gmail.com> wrote:
>=20
>> On Wednesday, July 12, 2017 at 7:47:05 PM UTC-4, Arthur O'Dwyer wrote:
>>> On Wednesday, July 12, 2017 at 2:53:19 AM UTC-7, d...@soundradix.com wr=
ote:
>>> Hi,
>>>=20
>>> Would anyone be interested in adding std::shift to <algorithm>?=20
>>>=20
>>> It would be similar to both:
>>> - std::rotate, but without moving the head elements back to the tail. T=
his would allow a more efficient implementation and clearer semantics in ca=
se rotation is not needed as well as correctness in case rotation is undesi=
red.
>>> - <algorithm>'s std::move/std::move_backward (depending on the shift di=
rection).
>>>=20
>>> std::shift should probably accommodate both left and right shifts by on=
e of:
>>> - giving it either begin() and end(), or rbegin() and rend(), similar t=
o how std::rotate works for both left and right rotations. The advantage is=
 compactness of the implementation.
>>> - allowing the shift count parameter to be either positive or negative.=
 The advantage is compactness, though it might not be clear which direction=
 is which - to be consistent with rotate, positive integers should shift to=
 the left.
>>> - having std::shift_right and std::shift_left functions. The advantage =
is clarity when calling the methods, although the same argument could be ma=
de for having separate std::rotate_left and std::rotate_right instead of st=
d::rotate, which we don't have.
>>=20
>> std::rotate is actually just a rotation; it doesn't need "left" or "righ=
t" qualification because they're 100% equivalent. Consider a classroom glob=
e with London in front, facing you. Now "rotate" the globe until Beijing is=
 in front. It doesn't matter if you rotate left or rotate right; the outcom=
e is exactly the same either way.
>> =20
>>> Here's a sample implementation of a shift to the right direction:
>>>=20
>>> template<class BidirIt>=20
>>> void shift_right(BidirIt first, BidirIt last, unsigned int n =3D 1)=20
>>> {=20
>>>     std::move_backward(first, last - n, last);=20
>>> }
>>>=20
>>> This demonstrates that while std::shift is implementable with std::move=
/std::move_backward,
>>> 1) It isn't immediately clear from the code (at least to my eyes) that =
this is a shift right, unless you are intimately familiar with std::move_ba=
ckward.
>>> 2) Different calls, either to std::move or to std::move_backward, are r=
equired, depending on the shift direction.
>>=20
>> If you're shifting the whole container's contents, you could use either =
of these:
>>     std::move(ctr.rbegin() + n, ctr.rend(), ctr.rbegin());
>>     std::move_backward(ctr.begin(), ctr.end() - n, ctr.end())?
>> I don't currently see the use-case for this "shift just a piece of a con=
tainer" algorithm, I mean as distinct from std::move and std::move_backward=
 which already exist. Do you have a use-case?
>=20
> The use-case would be anytime you'd want to use the code you just wrote. =
When you have a range and N, and you want to do a shift N units in that dir=
ection.
>=20
> The point of having it is one of clarification and user expectations. Yes=
, you can use `move` and `move_backward` to accomplish a shift. But conside=
r the two function calls:
>=20
> //A
> std::shift(rng.begin(), rng.end(), N);
>=20
> //B
> auto rrng =3D std::make_reverse_range(rng);
> std::move(rrng.begin() + N, rrng.end(), rrng.begin());
>=20
> A and B both do the same thing. But it's a lot easier to figure out what =
the code is actually accomplishing from looking at A than B.
>=20
> B gets even more obtuse confusing in a range-based world:
>=20
> //A
> std::shift(rng, N);
>=20
> //B
> auto rrng =3D std::make_reverse_range(rng);
> std::move(std::make_range(rrng.begin + N, rrng.end()), rrng.begin());
> --=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=
 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/isoc=
pp.org/d/msgid/std-proposals/c722a201-5c9c-4ac5-a1bd-e50beb6d7860%40isocpp.=
org.

--=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/1E3763D6-C8A5-471A-AA44-F5CFDEDD6D9E%40gmail.com=
..

--Apple-Mail-B758B76A-D759-4322-99A9-61165DC59A77
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div></div><div>Thanks for phrasing the=
 motivation so well Nicol.</div><div><br></div><div>Arthur, regarding speci=
fic use cases, any algorithm doing time series analysis (e.g. temperature t=
he last 20 days) could use this.</div><div><br></div><div>(A cyclical buffe=
r is an alternative, but one which isn't always preferrable.)</div><div><br=
>On 13 Jul 2017, at 4:43, Nicol Bolas &lt;<a href=3D"mailto:jmckesson@gmail=
..com">jmckesson@gmail.com</a>&gt; wrote:<br><br></div><blockquote type=3D"c=
ite"><div><div dir=3D"ltr">On Wednesday, July 12, 2017 at 7:47:05 PM UTC-4,=
 Arthur O'Dwyer wrote:<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">On Wednesday, July 12, 2017 at 2:53:19 AM UTC-7, <a>d...@soundradi=
x.com</a> wrote:<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">Hi=
,<div><br></div><div>Would anyone be interested in adding std::shift to &lt=
;algorithm&gt;?&nbsp;</div><div><br></div><div>It would be similar to both:=
</div><div>- std::rotate, but without moving the head elements back to the =
tail. This would allow a more efficient implementation and clearer semantic=
s in case rotation is not needed as well as correctness in case rotation is=
 undesired.</div><div>- &lt;algorithm&gt;'s std::move/std::move_backward (d=
epending on the shift direction).</div><div><br></div><div>std::shift shoul=
d probably accommodate both left and right shifts by one of:</div><div>- gi=
ving it either begin() and end(), or rbegin() and rend(), similar to how st=
d::rotate works for both left and right rotations. The advantage is compact=
ness of the implementation.</div><div>- allowing the shift count parameter =
to be either positive or negative. The advantage is compactness, though it =
might not be clear which direction is which - to be consistent with rotate,=
 positive integers should shift to the left.<br></div><div><div>- having st=
d::shift_right and std::shift_left functions. The advantage is clarity when=
 calling the methods, although the same argument could be made for having s=
eparate std::rotate_left and std::rotate_right instead of std::rotate, whic=
h we don't have.</div></div></div></blockquote><div><br></div><div>std::rot=
ate is actually just a rotation; it doesn't need "left" or "right" qualific=
ation because they're 100% equivalent. Consider a classroom globe with Lond=
on in front, facing you. Now "rotate" the globe until Beijing is in front. =
It doesn't matter if you rotate left or rotate right; the outcome is exactl=
y the same either way.</div><div>&nbsp;</div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div dir=3D"ltr"><div>Here's a sample implementation of a shift t=
o the right direction:<br></div><br><div style=3D"background-color:rgb(250,=
250,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div=
><span style=3D"color:#008">template</span><span style=3D"color:#660">&lt;<=
/span><span style=3D"color:#008">class</span><span style=3D"color:#000"> </=
span><span style=3D"color:#606">BidirIt</span><span style=3D"color:#660">&g=
t;</span><span style=3D"color:#000"> <br></span><span style=3D"color:#008">=
void</span><span style=3D"color:#000"> shift_right</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#606">BidirIt</span><span style=3D"co=
lor:#000"> first</span><span style=3D"color:#660">,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">BidirIt</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">last</span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">unsigned</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">int</span><span style=3D"color:#000"> n </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066=
">1</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> <b=
r></span><span style=3D"color:#660">{</span><span style=3D"color:#000"> <br=
>&nbsp; &nbsp; std</span><span style=3D"color:#660">::</span><span style=3D=
"color:#000">move_backward</span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#000">first</span><span style=3D"color:#660">,</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">last</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#660">-</span><span style=3D"=
color:#000"> n</span><span style=3D"color:#660">,</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#008">last</span><span style=3D"color:=
#660">);</span><span style=3D"color:#000"> <br></span><span style=3D"color:=
#660">}</span><span style=3D"color:#000"><br></span></div></code></div><div=
><br></div><div>This demonstrates that while std::shift is implementable wi=
th std::move/std::move_backward,</div><div>1) It isn't immediately clear fr=
om the code (at least to my eyes) that this is a shift right, unless you ar=
e intimately familiar with std::move_backward.</div><div>2) Different calls=
, either to std::move or to std::move_backward, are required, depending on =
the shift direction.</div></div></blockquote><div><br></div><div>If you're =
shifting the whole container's contents, you could use either of these:</di=
v><div>&nbsp; &nbsp; std::move(ctr.rbegin() + n, ctr.rend(), ctr.rbegin());=
</div><div>&nbsp; &nbsp; std::move_backward(ctr.begin()<wbr>, ctr.end() - n=
, ctr.end())?</div><div>I don't currently see the use-case for this "shift =
just a piece of a container" algorithm, I mean as distinct from std::move a=
nd std::move_backward which already exist. Do you have a use-case?</div></d=
iv></blockquote><div><br>The use-case would be anytime you'd want to use th=
e code you just wrote. When you have a range and N, and you want to do a sh=
ift N units in that direction.<br><br>The point of having it is one of clar=
ification and user expectations. Yes, you can use `move` and `move_backward=
` to accomplish a shift. But consider the two function calls:<br><br><div s=
tyle=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 1=
87); border-style: solid; border-width: 1px; overflow-wrap: break-word;" cl=
ass=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprin=
t"><span style=3D"color: #800;" class=3D"styled-by-prettify">//A</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>std</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">shift</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">rng</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">begin</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(),</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> rng</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">end</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(),</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> N</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">//B</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> rrng </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">make_reverse_=
range</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">rng</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>std</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">move</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">rrng</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">.</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">begin</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> N</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> rrng</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">end</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(),</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> rrng</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #008;" class=3D"styled-by-prettify">begin</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">());</span></d=
iv></code></div><br>A and B both do the same thing. But it's a <i>lot easie=
r</i> to figure out what the code is actually accomplishing from looking at=
 A than B.<br><br>B gets even more obtuse confusing in a range-based world:=
<br><br><div style=3D"background-color: rgb(250, 250, 250); border-color: r=
gb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: b=
reak-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">=
//A</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>std=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">shift</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">rng</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> N</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled-by-p=
rettify">//B</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rrng </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</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">make_reverse_range</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">rng</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>std</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">move</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">make_range</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">rrng</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">begin</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"> N</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rrng<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">end</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">()),</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> rrng</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">());</span></div></code></div></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/c722a201-5c9c-4ac5-a1bd-e50beb6d7860%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/c722a201-5c9c-4ac5-a1bd-e50beb6d=
7860%40isocpp.org</a>.<br>
</div></blockquote></body></html>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1E3763D6-C8A5-471A-AA44-F5CFDEDD6D9E%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1E3763D6-C8A5-471A-AA44-F5CFDEDD6D9E%=
40gmail.com</a>.<br />

--Apple-Mail-B758B76A-D759-4322-99A9-61165DC59A77--

.
