220 19105 <9af8d354-827e-4ca8-b565-6e589f1b09d3@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vlad from Moscow <vlad.moscow@mail.ru>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Specialization of std::stack for std::forward_list
Date: Thu, 16 Jul 2015 08:40:21 -0700 (PDT)
Lines: 190
Approved: news@gmane.org
Message-ID: <9af8d354-827e-4ca8-b565-6e589f1b09d3@isocpp.org>
References: <d51e20f7-665e-49f7-a3e8-caed3660563f@isocpp.org>
 <7f1a222e-5ba7-46dd-9a03-3be94e144e3f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_176_828721028.1437061221372"
X-Trace: ger.gmane.org 1437061226 452 80.91.229.3 (16 Jul 2015 15:40:26 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 16 Jul 2015 15:40:26 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXLLRHD7IDRBZVAT6WQKGQEJVL5FDQ@isocpp.org Thu Jul 16 17:40:25 2015
Return-path: <std-proposals+bncBCXLLRHD7IDRBZVAT6WQKGQEJVL5FDQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f198.google.com ([209.85.213.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBZVAT6WQKGQEJVL5FDQ@isocpp.org>)
	id 1ZFlGq-0000Bu-3J
	for gclcip-std-proposals@m.gmane.org; Thu, 16 Jul 2015 17:40:24 +0200
Original-Received: by igczg2 with SMTP id zg2sf27992206igc.3
        for <gclcip-std-proposals@m.gmane.org>; Thu, 16 Jul 2015 08:40:23 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=bzyF1WIcaD8aQSJzBfZlBix/dRBL4Ha38h9pTMok2sg=;
        b=IBIYdZwLQLtls201YFU+GiTilNnrKBv4MVhQQaV/EA/2xt0vcenWUQq+W5hCmQHFY8
         HdPDYhuQQrzUyKnoWnDxcRj+zjoeHLG3sMTpkWidsOKdBgmYTK2r2dqZXZvuJRXdOUEo
         Vzo7X3oQxMh37OuJOgDDlCt9Soc6sQbszLYbsAe1D/AyXUl0bE17N4u9/+lVCkooPzAT
         8kuSzwNJWdXeYDQorqZ6Dm/KHfGFibp0BjVixEbc07OxaSsyjttQ6Z7nWSdky0elWfmo
         AliwSs4NRPye2EdIiKhTbn1ky+YOI7TizrMCznFESVFU25m2meB1UTHD8itMeV5vERiI
         tOuA==
X-Gm-Message-State: ALoCoQkkiWqB5UVq4r00sMdWRIYC3bbod9KKWDNdml4mquw2k3CHDpPT+mxDbphA9hFOhWrND/TI
X-Received: by 10.50.17.10 with SMTP id k10mr4579665igd.8.1437061222962;
        Thu, 16 Jul 2015 08:40:22 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.94.70 with SMTP id f64ls1501230qge.86.gmail; Thu, 16 Jul
 2015 08:40:21 -0700 (PDT)
X-Received: by 10.140.25.211 with SMTP id 77mr226885qgt.41.1437061221912;
        Thu, 16 Jul 2015 08:40:21 -0700 (PDT)
In-Reply-To: <7f1a222e-5ba7-46dd-9a03-3be94e144e3f@isocpp.org>
X-Original-Sender: vlad.moscow@mail.ru
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:19105
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19105>

------=_Part_176_828721028.1437061221372
Content-Type: multipart/alternative; 
	boundary="----=_Part_177_387236219.1437061221372"

------=_Part_177_387236219.1437061221372
Content-Type: text/plain; charset=UTF-8



On Thursday, July 16, 2015 at 6:05:47 PM UTC+3, Sasha Unknown wrote:
>
> From point of view of pure logic, standard STL-supplied singly linked list 
> MUST be able to act as underlying implementation of standard STL-supplied 
> stack (as singly linked list is one of theoretically best ways to do stack).
> When I noticed that std::forward_list was added in c++11, my first thought 
> was: "Oh! They did a great mistake! They had to add std::backward_list 
> instead! As it's more natural to push/pop at the end, and std::stack 
> requires it."
> But on the other hand, Magnus Fromreide IS RIGHT that "it would be a 
> strange beast indeed as it won't support insert(iterator, value), 
> erase(iterator), begin() or end() (but rbegin() and rend())".
>
> So, my conclusion is:
>
> 1.
> Don't add specialization std::stack<T, std::forward_list<T>>. As it would 
> be quite unexpected to see front being used in case when with other 
> containers back is being used.
>

You are dealing with a stack not with lists. And the stack has a 
predictable behaviour. It is your choice what underlaying container to use. 
In any case it is hidden from the user.  
 

> 2.
> Don't add std::backward_list: as std::forward_list is already 
> standardized, and per written by Magnus Fromreide.
>
> Nobody is going to add std::backward_list. However a single linked list 
that allows to add elements to the tail is obviously needed. And I 
sugessted such a list somewhere here.
 

> 3.
> Add new adapter template class std::reverse_container<typename 
> BaseContainer>.
> It would be able to work as std::stack<T, 
> std::reverse_container<std::forward_list<T>>>, unless user will try to 
> access std::stack::size. However, nowhere in documentation should be stated 
> that it is for tying std::forward_list and std::stack together. It's just 
> general purpose adapter.
> It tries to publish all STL-stereotypical direction-neutral members of 
> BaseContainer, and to reverse all STL-stereotypical direction-sensitive 
> members of BaseContainer (with using std::reverse_iterator when needed). 
> Accessing a member of std::reverse_container<BaseContainer> that doesn't 
> have counterpart in BaseContainer causes template instantiation error. But 
> otherwise it is ok to use std::reverse_container with BaseContainer that 
> doesn't have all of STL-stereotypical members.
>
> Insetad of make the life easier you are trying to make the life harder.
 

> 4.
> Either add std::forward_list::size member that must act identically to 
> std::list::size.
> Or mark std::list::size member as obsolete/discouraged in documentation.
> Because the decision should be the same for std::list and 
> std::forward_list (at least, I see no reason for different decision on 
> std::forward_list::size and std::list::size).
>
> The specialization of std::stack for std:;forward_list may have not data 
member  size. But all specializations of std::stack shall have method clear 
that I also proposed.

Cheers.
>
> On Friday, September 6, 2013 at 8:37:38 PM UTC+3, Vlad from Moscow wrote:
>>
>> I would like to propose to include specialization of std::stack for 
>> std::forward_list. 
>>  
>> In fact std::forward_list has already all characteristics of a stack. 
>> There will be only one difference compared with the primary class 
>> std::stack:  the specialization will not contain member function size() 
>> because std::forward_list has no such member.
>>  
>> What will you say?
>>
>

-- 

--- 
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_177_387236219.1437061221372
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Thursday, July 16, 2015 at 6:05:47 PM UTC+3, Sasha Unknown wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padd=
ing-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1p=
x; border-left-style: solid;"><div dir=3D"ltr">From point of view of pure l=
ogic, standard STL-supplied singly linked list MUST be able to act as under=
lying implementation of standard STL-supplied stack (as singly linked list =
 is one of theoretically best ways to do stack).<br>When I noticed that std=
::forward_list was added in c++11, my first thought was: &quot;Oh! They did=
 a great mistake! They had to add std::backward_list instead! As it&#39;s m=
ore natural to push/pop at the end, and std::stack requires it.&quot;<br>Bu=
t on the other hand, Magnus Fromreide IS RIGHT that &quot;it would be a str=
ange beast indeed as it won&#39;t support insert(iterator, value), erase(it=
erator), begin() or end() (but rbegin() and rend())&quot;.<br><br>So, my co=
nclusion is:<br><br>1.<br>Don&#39;t add specialization std::stack&lt;T, std=
::forward_list&lt;T&gt;&gt;. As it would be quite unexpected to see front b=
eing used in case when with other containers back is being used.<br></div><=
/blockquote><div><br></div><div>You are dealing with a stack not with lists=
.. And the stack has a predictable behaviour. It is your choice what underla=
ying container to use. In any case it is hidden from the user. =C2=A0</div>=
<div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px=
 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); borde=
r-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr">2.<br>Don&#3=
9;t add std::backward_list: as std::forward_list is already standardized, a=
nd per written by Magnus Fromreide.<br><br></div></blockquote><div>Nobody i=
s=C2=A0going to add std::backward_list. However a single linked list that a=
llows to add elements to the tail is obviously needed. And I sugessted such=
 a list somewhere here.</div><div>=C2=A0</div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-col=
or: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;">=
<div dir=3D"ltr">3.<br>Add new adapter template class std::reverse_containe=
r&lt;typename BaseContainer&gt;.<br>It would be able to work as std::stack&=
lt;T, std::reverse_container&lt;std::forward_list&lt;T&gt;&gt;&gt;, unless =
user will try to access std::stack::size. However, nowhere in documentation=
 should be stated that it is for tying std::forward_list and std::stack tog=
ether. It&#39;s just general purpose adapter.<br>It tries to publish al<cod=
e></code><code></code>l STL-stereotypical direction-neutral members of Base=
Container, and to reverse all STL-stereotypical direction-sensitive members=
  of BaseContainer (with using std::reverse_iterator when needed). Accessin=
g a member of std::reverse_container&lt;BaseContainer&gt; that doesn&#39;t =
have counterpart in BaseContainer causes template instantiation error. But =
otherwise it is ok to use std::reverse_container with BaseContainer that do=
esn&#39;t have all of STL-stereotypical members.<br><br></div></blockquote>=
<div>Insetad of make the life easier you are trying=C2=A0to make the life h=
arder.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204,=
 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr">=
4.<br>Either add std::forward_list::size member that must act identically t=
o std::list::size.<br>Or mark std::list::size member as obsolete/discourage=
d in documentation.<br>Because the decision should be the same for std::lis=
t and std::forward_list (at least, I see no reason for different decision o=
n std::forward_list::size and std::list::size).<br><br></div></blockquote><=
div>The specialization of std::stack for std:;forward_list may have not dat=
a member=C2=A0=C2=A0size. But all specializations of std::stack shall have =
method clear that I also proposed.</div><div><br></div><blockquote class=3D=
"gmail_quote" 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;"><div dir=3D"ltr">Cheers.<br><br>On Friday, September 6, 2013 at 8:=
37:38 PM UTC+3, Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" st=
yle=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;"><div di=
r=3D"ltr"><div>I would like to propose to include specialization of std::st=
ack for std::forward_list. </div><div>=C2=A0</div><div>In fact std::forward=
_list has already all characteristics of a stack. There will be only one di=
fference compared with the primary class std::stack:=C2=A0 the specializati=
on will not contain member function size() because std::forward_list has no=
 such member.</div><div>=C2=A0</div><div>What will you say?</div></div></bl=
ockquote></div></blockquote>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
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 />

------=_Part_177_387236219.1437061221372--
------=_Part_176_828721028.1437061221372--

.
