220 6202 <CAOfiQqmvTsWx3oZBOMdDqM_BMwmQOm--7+n8Lw+LQ1zQtQcKgA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Richard Smith <richard@metafoo.co.uk>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Specialization of std::stack for std::forward_list
Date: Fri, 6 Sep 2013 17:14:38 -0700
Lines: 206
Approved: news@gmane.org
Message-ID: <CAOfiQqmvTsWx3oZBOMdDqM_BMwmQOm--7+n8Lw+LQ1zQtQcKgA@mail.gmail.com>
References: <d51e20f7-665e-49f7-a3e8-caed3660563f@isocpp.org>
	<5b046beb-f0c0-4cd2-96bb-bc7007da13e9@isocpp.org>
	<1111d35d-1a91-47b3-a2a4-01c2b91a6527@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=047d7bf0f67a70d88d04e5c00aa5
X-Trace: ger.gmane.org 1378512879 10564 80.91.229.3 (7 Sep 2013 00:14:39 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 7 Sep 2013 00:14:39 +0000 (UTC)
Cc: inkwizytoryankes@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDVNBJG4YAIBB3W7VGIQKGQEKOVRIII@isocpp.org Sat Sep 07 02:14:40 2013
Return-path: <std-proposals+bncBDVNBJG4YAIBB3W7VGIQKGQEKOVRIII@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qa0-f70.google.com ([209.85.216.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDVNBJG4YAIBB3W7VGIQKGQEKOVRIII@isocpp.org>)
	id 1VI6Ai-0003KB-Db
	for gclcip-std-proposals@m.gmane.org; Sat, 07 Sep 2013 02:14:40 +0200
Original-Received: by mail-qa0-f70.google.com with SMTP id ii20sf1918671qab.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 06 Sep 2013 17:14:39 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=mime-version:sender:in-reply-to:references:date:message-id:subject
         :from:to:cc:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe:content-type;
        bh=+0an8m5kLf7kuaVilyKtd5z/7nCnK/lUk/nbE/KfGyM=;
        b=WBCKCkVHXBhpOb1CSFgTqGV7o4PNmjSvaBOB9uGxT5Ddmj9OOfpmvOhAM41ia5vECe
         2o+zivwECsQfvDtBWstda/V0my9ZHUyL/Uhw8O6zDEYxrXVn9SvoR0biR0QChFkdvour
         zrlMVSuV7QpfQVub7xYoMDoLNTrtNbEUUGDH7z0QPuXReyv0qlZYjO8b2ipPhApWwQYx
         Wbj/ZryBKl/5mAzOhdSCCY1R+OWBC3jgZOk+BL+TAzflUX1Ax+XN6plL99BQMwihJFKp
         ca+q7VGoNEq8+uszhRszo3zxgfU0Gl3QRyXbYHbf1jZn9HstuaNyhKuaIu6a25CEyv2T
         RjFg==
X-Received: by 10.236.7.130 with SMTP id 2mr1750962yhp.4.1378512879542;
        Fri, 06 Sep 2013 17:14:39 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.5.9 with SMTP id o9ls362010qeo.49.gmail; Fri, 06 Sep 2013
 17:14:38 -0700 (PDT)
X-Received: by 10.58.127.202 with SMTP id ni10mr412729veb.27.1378512878748;
        Fri, 06 Sep 2013 17:14:38 -0700 (PDT)
Original-Received: from mail-ve0-x235.google.com (mail-ve0-x235.google.com [2607:f8b0:400c:c01::235])
        by mx.google.com with ESMTPS id ed9si120761vcb.6.1969.12.31.16.00.00
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 06 Sep 2013 17:14:38 -0700 (PDT)
Received-SPF: pass (google.com: domain of metafoo@gmail.com designates 2607:f8b0:400c:c01::235 as permitted sender) client-ip=2607:f8b0:400c:c01::235;
Original-Received: by mail-ve0-f181.google.com with SMTP id oy12so2141475veb.12
        for <std-proposals@isocpp.org>; Fri, 06 Sep 2013 17:14:38 -0700 (PDT)
X-Received: by 10.220.181.136 with SMTP id by8mr4917134vcb.11.1378512878489;
 Fri, 06 Sep 2013 17:14:38 -0700 (PDT)
Original-Sender: metafoo@gmail.com
Original-Received: by 10.58.98.1 with HTTP; Fri, 6 Sep 2013 17:14:38 -0700 (PDT)
In-Reply-To: <1111d35d-1a91-47b3-a2a4-01c2b91a6527@isocpp.org>
X-Original-Sender: richard@metafoo.co.uk
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of metafoo@gmail.com designates 2607:f8b0:400c:c01::235 as permitted
 sender) smtp.mail=metafoo@gmail.com;       dkim=pass header.i=@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: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:6202
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/6202>

--047d7bf0f67a70d88d04e5c00aa5
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

On Fri, Sep 6, 2013 at 4:48 PM, Vlad from Moscow <vlad.moscow@mail.ru>wrote=
:

> I doi not agree that we need a new version of stack. All what we need we
> already have. Moreover stack does not require member function size(). It =
is
> unnecessary function. What is size()? Inf act is is an analogy of an
> iterator. Consider using size with an array something as
>
> for ( int i =3D 0; i < n; i++ ) a[i] =3D i;
>
> a + 0 and a + n give us iterators. However stack has no iterators so it
> does not need the size() function. The logic of functionality of the stac=
k
> is simple. We are popping out elements of the stack while it is not empty=
..
>
> What we need is simply a specialization of std::stack for
> std::forward_list. std::forward_list has all functionality of the stack.
>

We risk introducing surprising behavior if we add support for this. Right
now, std::stack::push adds elements to the *end* of the stack, and this is
an observable property in various ways (for instance, due to the container
member being protected rather than private). Consider:

template<template<typename...> struct Container>
struct MyStack : public std::stack<int, Container<int>> {
  using stack::stack;
  void print() {
    for (int n : this->c)
      std::cout << n << std::endl;
  }
};

If we taught std::stack to switch to using push_front instead of push_back
when its container is a std::forward_list,
MyStack<std::forward_list>::print would print in the opposite order from
MyStack<any_other_container>::print.

This seems a bit too reminiscent of std::vector<bool> for comfort.

=D3=D5=C2=C2=CF=D4=C1, 7 =D3=C5=CE=D4=D1=C2=D2=D1 2013 =C7., 3:14:13 UTC+4 =
=D0=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8
> inkwizyt...@gmail.com =CE=C1=D0=C9=D3=C1=CC:
>
>>
>>
>> On Friday, September 6, 2013 7:37:38 PM UTC+2, 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?
>>>
>>
>> why no `size()`? nobody can access inner list ergo stack can easy
>> determine size in const time. `std::stack` require only:
>>
>> back
>> push_back
>> pop_back
>>
>> that can be in case `std::forward_list` inverted to:
>>
>> front
>> push_front
>> pop_front
>>
>> maybe we need simple new version of stack? `std::stack_front`?
>>
>>
>>
>>  --
>
> ---
> 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/.
>

--=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/.

--047d7bf0f67a70d88d04e5c00aa5
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Fri, Sep 6, 2013 at 4:48 PM, Vlad from Moscow <span dir=
=3D"ltr">&lt;<a href=3D"mailto:vlad.moscow@mail.ru" target=3D"_blank">vlad.=
moscow@mail.ru</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div cla=
ss=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>I doi not agree that w=
e need a new version of stack. All what we need we already have. Moreover s=
tack does not require member function size(). It is unnecessary function. W=
hat is size()? Inf act is is an analogy of an iterator. Consider using size=
 with an array something as</div>
<div>=9A</div><div>for ( int i =3D 0; i &lt; n; i++ ) a[i] =3D i;</div><div=
>=9A</div><div>a + 0 and a + n give us iterators. However stack has no iter=
ators so it does not need the size() function. The logic of functionality o=
f the stack is simple. We are popping out elements of the stack while it is=
 not empty.</div>
<div>=9A</div><div>What we need is simply a specialization of std::stack fo=
r std::forward_list. std::forward_list has all functionality of the stack.<=
/div></div></blockquote><div><br></div><div>We risk introducing surprising =
behavior if we add support for this. Right now, std::stack::push adds eleme=
nts to the *end* of the stack, and this is an observable property in variou=
s ways (for instance, due to the container member being protected rather th=
an private). Consider:</div>
<div><br></div><div>template&lt;template&lt;typename...&gt; struct Containe=
r&gt;</div><div>struct MyStack : public std::stack&lt;int, Container&lt;int=
&gt;&gt; {</div><div>=9A using stack::stack;</div><div>=9A void print() {</=
div>
<div>=9A =9A for (int n : this-&gt;c)</div><div>=9A =9A =9A std::cout &lt;&=
lt; n &lt;&lt; std::endl;</div><div>=9A }</div><div>};<br></div><div><br></=
div><div>If we taught std::stack to switch to using push_front instead of p=
ush_back when its container is a std::forward_list, MyStack&lt;std::forward=
_list&gt;::print would print in the opposite order from MyStack&lt;any_othe=
r_container&gt;::print.</div>
<div><br></div><div>This seems a bit too reminiscent of std::vector&lt;bool=
&gt; for comfort.</div><div><br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr">
<div>=D3=D5=C2=C2=CF=D4=C1, 7 =D3=C5=CE=D4=D1=C2=D2=D1 2013=9A=C7., 3:14:13=
 UTC+4 =D0=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8 <a href=3D"mailto:inkwizyt...@g=
mail.com" target=3D"_blank">inkwizyt...@gmail.com</a> =CE=C1=D0=C9=D3=C1=CC=
:</div><div><div class=3D"h5"><blockquote class=3D"gmail_quote" style=3D"ma=
rgin: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"><br><br>On Friday, September 6, 2013 7:37:38 PM UTC+2, Vla=
d from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-lef=
t-width:1px;border-left-style:solid">
<div dir=3D"ltr"><div>I would like to propose to include specialization of =
std::stack for std::forward_list. </div><div>=9A</div><div>In fact std::for=
ward_list has already all characteristics of a stack. There will be only on=
e difference compared with the primary class std::stack:=9A the specializat=
ion will not contain member function size() because std::forward_list has n=
o such member.</div>
<div>=9A</div><div>What will you say?</div></div></blockquote><div>=9A</div=
><div><font><span style=3D"font-family:arial,sans-serif">why no `size()`? n=
obody can access inner list ergo stack can easy determine size in const tim=
e. `std::stack` require only:<br>
<br>back<br>push_back<br>pop_back<br><br>that can be in case `std::forward_=
list` inverted to:<br><br>front<br>push_front<br>pop_front<br><br>maybe we =
need simple new version of stack? `std::stack_front`?<br><br></span></font>=
<p>
<font><span style=3D"font-family:arial,sans-serif"><br></span></font></p><p=
><br></p></div></div></blockquote></div></div></div><div class=3D"HOEnZb"><=
div class=3D"h5">

<p></p>

-- <br>
=9A<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%2Bunsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7bf0f67a70d88d04e5c00aa5--

.
