Topic: Runtime stack list


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Fri, 23 Jan 2015 10:29:30 -0800 (PST)
Raw View
------=_Part_738_1493250644.1422037770945
Content-Type: multipart/alternative;
 boundary="----=_Part_739_1569674866.1422037770945"

------=_Part_739_1569674866.1422037770945
Content-Type: text/plain; charset=UTF-8

I would be helpful to have a structure whereby values could be pushed onto
the stack, then used.

e.g. to convert an unsigned integer to decimal:

void print(unsigned u) {
  runtime_stack<char> digits;
  do { // put condition at the bottom in case u == 0
    digits.push(static_convert<char>(u % 10 + '0'));
    u /= 10;
  } while (u);
  do {
    std::cout << digits.top();
    digits.pop();
  } while (!digits.empty());
}



or, reading a list from a file:

std::vector<int> read(std::istream &i) {
  runtime_stack<int> numbers;
  for (;;) {
    int next;
    i << next;
    if (next == -1)
      break;
    numbers.push(next);
  }
  return std::vector<int>{numbers}; // Conversion does not need to
anticipate the number of numbers prior to filling, nor does it need to
shrink_to_fit
}


Note, the conversion to std::vector, for a POD, would just be a single
allocation, followed by a memcpy.

--

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

<div dir=3D"ltr">I would be helpful to have a structure whereby values coul=
d be pushed onto the stack, then used.<br><br>e.g. to convert an unsigned i=
nteger to decimal:<br><br><div class=3D"prettyprint" style=3D"background-co=
lor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: so=
lid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled=
-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">p=
rint</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">unsigned</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> u</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)</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>&nbsp; runtime_stack</span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&lt;char&gt;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> digits</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">do</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"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// put=
 condition at the bottom in case u =3D=3D 0</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; digits</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">push</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">static_convert</span><span style=3D"color: #080;" c=
lass=3D"styled-by-prettify">&lt;char&gt;</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">u </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">%</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</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: #=
080;" class=3D"styled-by-prettify">'0'</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">));</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>&nbsp; &nbsp; u </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">/=3D</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styl=
ed-by-prettify">10</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>&nbsp; </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">while</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">u</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">do</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>&nbs=
p; &nbsp; std</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">::</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"> digits</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">top</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; digits</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">pop</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>&nbsp; </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">while</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(!<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">digits</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">empty</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">());</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br><br></span></div></code></div><br><br>or, rea=
ding a list from a file:<br><br><div class=3D"prettyprint" style=3D"backgro=
und-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-sty=
le: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pretty=
print"><div class=3D"subprettyprint"><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-prett=
ify">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=
"> read</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">istream </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">i</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">)</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"><br>&nbsp; runtime_stack</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"> numbers</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">for</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </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">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">next</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; i </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: #008;" class=
=3D"styled-by-prettify">next</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>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">if</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">next</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">=3D=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: #066;" =
class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>&nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">break</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>&nbsp; &nbsp; numbers</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">push</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">next</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">return</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"colo=
r: #000;" class=3D"styled-by-prettify">vector</span><span style=3D"color: #=
080;" class=3D"styled-by-prettify">&lt;int&gt;</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">numbers</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: #800;" class=3D"styled-by-pre=
ttify">// Conversion does not need to anticipate the number of numbers prio=
r to filling, nor does it need to shrink_to_fit</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><br>Note, the con=
version to std::vector, for a POD, would just be a single allocation, follo=
wed by a memcpy.<br></div>

<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_739_1569674866.1422037770945--
------=_Part_738_1493250644.1422037770945--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 23 Jan 2015 10:38:39 -0800
Raw View
On Friday 23 January 2015 10:29:30 Douglas Boffey wrote:
> I would be helpful to have a structure whereby values could be pushed onto
> the stack, then used.
[snip]

What's wrong with std::stack?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
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: Douglas Boffey <douglas.boffey@gmail.com>
Date: Fri, 23 Jan 2015 11:04:09 -0800 (PST)
Raw View
------=_Part_16_326302022.1422039849554
Content-Type: multipart/alternative;
 boundary="----=_Part_17_1001158638.1422039849554"

------=_Part_17_1001158638.1422039849554
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

It doesn=E2=80=99t do what I want, namely to have avariable sized list with=
out the=20
need for allocation/deallocation from the free store.  Instead, it should=
=20
push/pop from the runtime stack.  I=E2=80=99m sorry if I didn=E2=80=99t mak=
e my intentions=20
clear.

On Friday, 23 January 2015 18:38:49 UTC, Thiago Macieira wrote:
>
> On Friday 23 January 2015 10:29:30 Douglas Boffey wrote:=20
> > I would be helpful to have a structure whereby values could be pushed=
=20
> onto=20
> > the stack, then used.=20
> [snip]=20
>
> What's wrong with std::stack?=20
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>    Software Architect - Intel Open Source Technology Center=20
>       PGP/GPG: 0x6EF45358; fingerprint:=20
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358=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_17_1001158638.1422039849554
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">It doesn=E2=80=99t do what I want, namely to have avariabl=
e sized list without the need for allocation/deallocation from the free sto=
re.&nbsp; Instead, it should push/pop from the runtime stack.&nbsp; I=E2=80=
=99m sorry if I didn=E2=80=99t make my intentions clear.<br><br>On Friday, =
23 January 2015 18:38:49 UTC, Thiago Macieira  wrote:<blockquote class=3D"g=
mail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc sol=
id;padding-left: 1ex;">On Friday 23 January 2015 10:29:30 Douglas Boffey wr=
ote:
<br>&gt; I would be helpful to have a structure whereby values could be pus=
hed onto
<br>&gt; the stack, then used.
<br>[snip]
<br>
<br>What's wrong with std::stack?
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNE=
swDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=3D'http://w=
ww.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg=
\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;">macieira.info</a> - th=
iago (AT) <a href=3D"http://kde.org" target=3D"_blank" rel=3D"nofollow" onm=
ousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fkde.org=
\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return tr=
ue;" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fkde=
..org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';retur=
n true;">kde.org</a>
<br>&nbsp; &nbsp;Software Architect - Intel Open Source Technology Center
<br>&nbsp; &nbsp; &nbsp; PGP/GPG: 0x6EF45358; fingerprint:
<br>&nbsp; &nbsp; &nbsp; E067 918B B660 DBD1 105C &nbsp;966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote></div>

<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_17_1001158638.1422039849554--
------=_Part_16_326302022.1422039849554--

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Fri, 23 Jan 2015 13:31:36 -0600
Raw View
--089e01634ddaa5d4a7050d56d83e
Content-Type: text/plain; charset=UTF-8

On 23 January 2015 at 12:29, Douglas Boffey <douglas.boffey@gmail.com>
wrote:

> I would be helpful to have a structure whereby values could be pushed onto
> the stack, then used.


What happens if you have more than one stack:

void a()
{
    runtime_stack<int> s1;
    runtime_stack<int> s2;

    s1.push(2);
    s2.push(3);
    s1.push(5);
}
--
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

--

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

--089e01634ddaa5d4a7050d56d83e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra">On 23 January 2015 at 12:29, Do=
uglas Boffey <span dir=3D"ltr">&lt;<a href=3D"mailto:douglas.boffey@gmail.c=
om" target=3D"_blank">douglas.boffey@gmail.com</a>&gt;</span> wrote:<br><di=
v class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0=
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I would be helpful t=
o have a structure whereby values could be pushed onto the stack, then used=
..</blockquote></div><br></div><div class=3D"gmail_extra">What happens if yo=
u have more than one stack:<br><br></div><div class=3D"gmail_extra">void a(=
)<br>{<br></div><div class=3D"gmail_extra">=C2=A0=C2=A0=C2=A0 runtime_stack=
&lt;int&gt; s1;<br></div><div class=3D"gmail_extra">=C2=A0=C2=A0=C2=A0 runt=
ime_stack&lt;int&gt; s2;<br><br></div><div class=3D"gmail_extra">=C2=A0=C2=
=A0=C2=A0 s1.push(2);<br></div><div class=3D"gmail_extra">=C2=A0=C2=A0=C2=
=A0 s2.push(3);<br></div><div class=3D"gmail_extra">=C2=A0=C2=A0=C2=A0 s1.p=
ush(5);<br></div><div class=3D"gmail_extra">}<br></div><div class=3D"gmail_=
extra">-- <br><div class=3D"gmail_signature">=C2=A0Nevin &quot;:-)&quot; Li=
ber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_b=
lank">nevin@eviloverlord.com</a>&gt;=C2=A0 (847) 691-1404</div>
</div></div>

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

--089e01634ddaa5d4a7050d56d83e--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Fri, 23 Jan 2015 19:49:38 +0000
Raw View
--001a11c1efdeba958d050d5716d7
Content-Type: text/plain; charset=UTF-8

UB.

Hopefully, with compiler support, more than one runtime stack in a single
execution frame should at least be warned against.

On Fri, Jan 23, 2015 at 7:31 PM, Nevin Liber <nevin@eviloverlord.com> wrote:

> On 23 January 2015 at 12:29, Douglas Boffey <douglas.boffey@gmail.com>
> wrote:
>
>> I would be helpful to have a structure whereby values could be pushed
>> onto the stack, then used.
>
>
> What happens if you have more than one stack:
>
> void a()
> {
>     runtime_stack<int> s1;
>     runtime_stack<int> s2;
>
>     s1.push(2);
>     s2.push(3);
>     s1.push(5);
> }
> --
>  Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404
>
> --
>
> ---
> 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/.
>

--

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

--001a11c1efdeba958d050d5716d7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>UB.<br><br></div>Hopefully, with compiler support, mo=
re than one runtime stack in a single execution frame should at least be wa=
rned against.<br></div><div class=3D"gmail_extra"><br><div class=3D"gmail_q=
uote">On Fri, Jan 23, 2015 at 7:31 PM, Nevin Liber <span dir=3D"ltr">&lt;<a=
 href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlor=
d.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><span class=3D""><div class=3D"gmail_extra">On 23 January 2015 at 12:29=
, Douglas Boffey <span dir=3D"ltr">&lt;<a href=3D"mailto:douglas.boffey@gma=
il.com" target=3D"_blank">douglas.boffey@gmail.com</a>&gt;</span> wrote:<br=
><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"marg=
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I would be helpf=
ul to have a structure whereby values could be pushed onto the stack, then =
used.</blockquote></div><br></div></span><div class=3D"gmail_extra">What ha=
ppens if you have more than one stack:<br><br></div><div class=3D"gmail_ext=
ra">void a()<br>{<br></div><div class=3D"gmail_extra">=C2=A0=C2=A0=C2=A0 ru=
ntime_stack&lt;int&gt; s1;<br></div><div class=3D"gmail_extra">=C2=A0=C2=A0=
=C2=A0 runtime_stack&lt;int&gt; s2;<br><br></div><div class=3D"gmail_extra"=
>=C2=A0=C2=A0=C2=A0 s1.push(2);<br></div><div class=3D"gmail_extra">=C2=A0=
=C2=A0=C2=A0 s2.push(3);<br></div><div class=3D"gmail_extra">=C2=A0=C2=A0=
=C2=A0 s1.push(5);<br></div><div class=3D"gmail_extra">}<span class=3D"HOEn=
Zb"><font color=3D"#888888"><br></font></span></div><span class=3D"HOEnZb">=
<font color=3D"#888888"><div class=3D"gmail_extra">-- <br><div>=C2=A0Nevin =
&quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlord=
..com" target=3D"_blank">nevin@eviloverlord.com</a>&gt;=C2=A0 <a href=3D"tel=
:%28847%29%20691-1404" value=3D"+18476911404" target=3D"_blank">(847) 691-1=
404</a></div>
</div></font></span></div><div class=3D"HOEnZb"><div class=3D"h5">

<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" 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>

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

--001a11c1efdeba958d050d5716d7--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 23 Jan 2015 14:07:37 -0800
Raw View
On Friday 23 January 2015 11:04:09 Douglas Boffey wrote:
> It doesn=E2=80=99t do what I want, namely to have avariable sized list wi=
thout the
> need for allocation/deallocation from the free store.  Instead, it should
> push/pop from the runtime stack.  I=E2=80=99m sorry if I didn=E2=80=99t m=
ake my intentions
> clear.

Before we go there, we need to solve the problem of variable-sized arrays o=
n=20
the stack. You may remember that this was removed from C++14.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

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

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 24 Jan 2015 09:03:25 +0800
Raw View
--Apple-Mail=_EDD379C8-42DB-44FE-BA72-E3781BFF4F32
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9301=E2=80=9324, at 3:49 AM, Douglas Boffey <douglas.boffey=
@gmail.com <mailto:douglas.boffey@gmail.com>> wrote:
>=20
> Hopefully, with compiler support, more than one runtime stack in a single=
 execution frame should at least be warned against.

Or, the implementation could provide only one runtime stack. It could be ca=
lled alloca.

(NB: the existence of alloca and the ability to call it twice in a function=
 are non-standard. YMMV. But, it does have a lot of miles on it.)

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

--Apple-Mail=_EDD379C8-42DB-44FE-BA72-E3781BFF4F32
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3D=
utf-8"><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf=
-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space;" class=3D""><br class=3D""><div clas=
s=3D""><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=
=9301=E2=80=9324, at 3:49 AM, Douglas Boffey &lt;<a href=3D"mailto:douglas.=
boffey@gmail.com" class=3D"">douglas.boffey@gmail.com</a>&gt; wrote:</div><=
br class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" cla=
ss=3D""><div class=3D"">Hopefully, with compiler support, more than one run=
time stack in a single execution frame should at least be warned against.</=
div></div></div></blockquote><div class=3D""><br class=3D""></div><div clas=
s=3D"">Or, the implementation could provide only one runtime stack. It coul=
d be called <font face=3D"Courier" class=3D"">alloca</font>.</div><div clas=
s=3D""><br class=3D""></div><div class=3D"">(NB: the existence of <font fac=
e=3D"Courier" class=3D"">alloca</font> and the ability to call it twice in =
a function are non-standard. YMMV. But, it does have a lot of miles on it.)=
</div></div></body></html>

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

--Apple-Mail=_EDD379C8-42DB-44FE-BA72-E3781BFF4F32--

.


Author: =?UTF-8?Q?P=C3=A9ter?= <mitchnull@gmail.com>
Date: Mon, 26 Jan 2015 00:15:15 -0800 (PST)
Raw View
------=_Part_75_1422631495.1422260115564
Content-Type: multipart/alternative;
 boundary="----=_Part_76_309832072.1422260115564"

------=_Part_76_309832072.1422260115564
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

How about using an allocator like Howard Hinnant's stack_alloc=20
<http://howardhinnant.github.io/stack_alloc.html> ?

regards,
mitch

On Friday, January 23, 2015 at 8:04:09 PM UTC+1, Douglas Boffey wrote:
>
> It doesn=E2=80=99t do what I want, namely to have avariable sized list wi=
thout the=20
> need for allocation/deallocation from the free store.  Instead, it should=
=20
> push/pop from the runtime stack.  I=E2=80=99m sorry if I didn=E2=80=99t m=
ake my intentions=20
> clear.
>
> On Friday, 23 January 2015 18:38:49 UTC, Thiago Macieira wrote:
>>
>> On Friday 23 January 2015 10:29:30 Douglas Boffey wrote:=20
>> > I would be helpful to have a structure whereby values could be pushed=
=20
>> onto=20
>> > the stack, then used.=20
>> [snip]=20
>>
>> What's wrong with std::stack?=20
>> --=20
>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>>    Software Architect - Intel Open Source Technology Center=20
>>       PGP/GPG: 0x6EF45358; fingerprint:=20
>>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358=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_76_309832072.1422260115564
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">How about using an allocator like Howard Hinnant's&nbsp;<a=
 href=3D"http://howardhinnant.github.io/stack_alloc.html">stack_alloc</a>&n=
bsp;?<br><br>regards,<div>mitch</div><div><br>On Friday, January 23, 2015 a=
t 8:04:09 PM UTC+1, Douglas Boffey wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div dir=3D"ltr">It doesn=E2=80=99t do what I want, namely to ha=
ve avariable sized list without the need for allocation/deallocation from t=
he free store.&nbsp; Instead, it should push/pop from the runtime stack.&nb=
sp; I=E2=80=99m sorry if I didn=E2=80=99t make my intentions clear.<br><br>=
On Friday, 23 January 2015 18:38:49 UTC, Thiago Macieira  wrote:<blockquote=
 class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px =
#ccc solid;padding-left:1ex">On Friday 23 January 2015 10:29:30 Douglas Bof=
fey wrote:
<br>&gt; I would be helpful to have a structure whereby values could be pus=
hed onto
<br>&gt; the stack, then used.
<br>[snip]
<br>
<br>What's wrong with std::stack?
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"n=
ofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.co=
m/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEsw=
DUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=3D'http://www=
..google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\7=
5AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;">macieira.info</a> - thia=
go (AT) <a href=3D"http://kde.org" rel=3D"nofollow" target=3D"_blank" onmou=
sedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fkde.org\4=
6sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fkde.o=
rg\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return =
true;">kde.org</a>
<br>&nbsp; &nbsp;Software Architect - Intel Open Source Technology Center
<br>&nbsp; &nbsp; &nbsp; PGP/GPG: 0x6EF45358; fingerprint:
<br>&nbsp; &nbsp; &nbsp; E067 918B B660 DBD1 105C &nbsp;966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote></div></blockquote></div></div>

<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_76_309832072.1422260115564--
------=_Part_75_1422631495.1422260115564--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Mon, 26 Jan 2015 08:37:08 +0000
Raw View
Thanks.  Seems far better idea.

On 1/26/15, P=C3=A9ter <mitchnull@gmail.com> wrote:
> How about using an allocator like Howard Hinnant's stack_alloc
> <http://howardhinnant.github.io/stack_alloc.html> ?
>
> regards,
> mitch
>
> On Friday, January 23, 2015 at 8:04:09 PM UTC+1, Douglas Boffey wrote:
>>
>> It doesn=E2=80=99t do what I want, namely to have avariable sized list w=
ithout the
>>
>> need for allocation/deallocation from the free store.  Instead, it shoul=
d
>>
>> push/pop from the runtime stack.  I=E2=80=99m sorry if I didn=E2=80=99t =
make my intentions
>>
>> clear.
>>
>> On Friday, 23 January 2015 18:38:49 UTC, Thiago Macieira wrote:
>>>
>>> On Friday 23 January 2015 10:29:30 Douglas Boffey wrote:
>>> > I would be helpful to have a structure whereby values could be pushed
>>> onto
>>> > the stack, then used.
>>> [snip]
>>>
>>> What's wrong with std::stack?
>>> --
>>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>>>    Software Architect - Intel Open Source Technology Center
>>>       PGP/GPG: 0x6EF45358; fingerprint:
>>>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>>>
>>>
>
> --
>
> ---
> 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/.

.


Author: David Krauss <potswa@gmail.com>
Date: Mon, 26 Jan 2015 18:10:16 +0800
Raw View
--Apple-Mail=_0B861846-0D31-44EC-B1E2-C6886F799C2D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9301=E2=80=9326, at 4:37 PM, Douglas Boffey <douglas.boffey=
@gmail.com> wrote:
>=20
> Thanks.  Seems far better idea.

Arena allocators are a great idea, but they solve a different problem.

Also, because C++ defines no interface for resizing allocation blocks, it c=
an be hard to avoid fragmentation when using something like short_alloc wit=
h std::vector. Your proposal is actually all about resizing.

Giving short_alloc a once-over, pointer_in_buffer needs to use std::less in=
stead of the built-in operator. But that might be a protest rather than an =
error. :P

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

--Apple-Mail=_0B861846-0D31-44EC-B1E2-C6886F799C2D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9301=
=E2=80=9326, at 4:37 PM, Douglas Boffey &lt;<a href=3D"mailto:douglas.boffe=
y@gmail.com" class=3D"">douglas.boffey@gmail.com</a>&gt; wrote:</div><br cl=
ass=3D"Apple-interchange-newline"><div class=3D""><span style=3D"font-famil=
y: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; fo=
nt-weight: normal; letter-spacing: normal; line-height: normal; orphans: au=
to; text-align: start; text-indent: 0px; text-transform: none; white-space:=
 normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; f=
loat: none; display: inline !important;" class=3D"">Thanks. &nbsp;Seems far=
 better idea.</span><br style=3D"font-family: Helvetica; font-size: 12px; f=
ont-style: normal; font-variant: normal; font-weight: normal; letter-spacin=
g: normal; line-height: normal; orphans: auto; text-align: start; text-inde=
nt: 0px; text-transform: none; white-space: normal; widows: auto; word-spac=
ing: 0px; -webkit-text-stroke-width: 0px;" class=3D""></div></blockquote><d=
iv><br class=3D""></div></div>Arena allocators are a great idea, but they s=
olve a different problem.<div class=3D""><br class=3D""></div><div class=3D=
"">Also, because C++ defines no interface for resizing allocation blocks, i=
t can be hard to avoid fragmentation when using something like <font face=
=3D"Courier" class=3D"">short_alloc</font> with <font face=3D"Courier" clas=
s=3D"">std::vector</font>. Your proposal is actually all about resizing.</d=
iv><div class=3D""><br class=3D""></div><div class=3D"">Giving&nbsp;<span s=
tyle=3D"font-family: Courier;" class=3D"">short_alloc</span>&nbsp;a once-ov=
er, <font face=3D"Courier" class=3D"">pointer_in_buffer</font> needs to use=
 <font face=3D"Courier" class=3D"">std::less</font> instead of the built-in=
 operator. But that might be a protest rather than an error. :P</div></body=
></html>

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

--Apple-Mail=_0B861846-0D31-44EC-B1E2-C6886F799C2D--

.


Author: Sean Middleditch <sean.middleditch@gmail.com>
Date: Mon, 26 Jan 2015 15:47:04 -0800 (PST)
Raw View
------=_Part_3910_384482433.1422316024686
Content-Type: multipart/alternative;
 boundary="----=_Part_3911_217957608.1422316024686"

------=_Part_3911_217957608.1422316024686
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Monday, January 26, 2015 at 12:15:15 AM UTC-8, P=C3=A9ter wrote:
>
> How about using an allocator like Howard Hinnant's stack_alloc=20
> <http://howardhinnant.github.io/stack_alloc.html> ?
>
>>
>>>
Because std::vector does not grow in any explicitly-known increments you=20
can't know for sure whether a stack_alloc<int, 4> will actually be used=20
fully or not. Some vectors might have a smallest non-zero capacity of 8=20
elements or more (seen 'em) and hence never actually be able to fit within=
=20
the space of the stack_alloc<int, 4>. A stack_alloc<int, 7> would surely=20
not be used fully even by 'normal' vectors. You would have to be sure to=20
explicitly call reserve() to get full and correct use of the allocator,=20
which makes it kinda weird and special and non-obvious (you have to set a=
=20
template parameter of N and call a runtime function with N).

For node-based containers, the stack_alloc<int, 4> is space for 4 integers=
=20
but how many nodes? 2? 1 and some wasted space? None at all?

Some possible container-allocator interface fixes to make an allocator work=
=20
reliably here:
1) allow the container to get an "initial" space/size from an allocator,=20
which would usually be nullptr/0 but would be _buf/N for stack_alloc and=20
similar allocators
2) clearly define the allocation and growth for vector and similar types so=
=20
that it's knowable whether stack_alloc<T, N> would result in used space for=
=20
any size N when automatic growth is used (rather than using reserve)
3) expose the node type or node size of node-based containers (and hope you=
=20
don't have multiple node types/sizes anytime you need stack_alloc) so the=
=20
user or allocator can make a large enough buffer for N nodes

I do think that using allocators is the right approach for the standards=20
process over one-off containers with slight variations in behavior.

But IMO right now the allocator approach has usability gotchas that=20
outweigh the benefit of a custom container with well-defined allocation=20
patterns in user code. Forgetting a reserve() call - or letting it get out=
=20
of sync with the stack_alloc size during maintenance - is just far too easy=
=20
of a mistake to make.

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

<div dir=3D"ltr">On Monday, January 26, 2015 at 12:15:15 AM UTC-8, P=C3=A9t=
er 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">How =
about using an allocator like Howard Hinnant's&nbsp;<a href=3D"http://howar=
dhinnant.github.io/stack_alloc.html" target=3D"_blank" rel=3D"nofollow" onm=
ousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fhowardh=
innant.github.io%2Fstack_alloc.html\46sa\75D\46sntz\0751\46usg\75AFQjCNGJLw=
XPxcqUVobfQRHPM5zqC_MhpQ';return true;" onclick=3D"this.href=3D'http://www.=
google.com/url?q\75http%3A%2F%2Fhowardhinnant.github.io%2Fstack_alloc.html\=
46sa\75D\46sntz\0751\46usg\75AFQjCNGJLwXPxcqUVobfQRHPM5zqC_MhpQ';return tru=
e;">stack_alloc</a>&nbsp;?<br><div><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"><blockquote class=3D"gmail_quote" style=3D"margin:0;margi=
n-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote>=
</div></blockquote></div></div></blockquote><div><br></div><div>Because std=
::vector does not grow in any explicitly-known increments you can't know fo=
r sure whether a stack_alloc&lt;int, 4&gt; will actually be used fully or n=
ot. Some vectors might have a smallest non-zero capacity of 8 elements or m=
ore (seen 'em) and hence never actually be able to fit within the space of =
the stack_alloc&lt;int, 4&gt;. A stack_alloc&lt;int, 7&gt; would surely not=
 be used fully even by 'normal' vectors. You would have to be sure to expli=
citly call reserve() to get full and correct use of the allocator, which ma=
kes it kinda weird and special and non-obvious (you have to set a template =
parameter of N and call a runtime function with N).</div><div><br></div><di=
v>For node-based containers, the stack_alloc&lt;int, 4&gt; is space for 4 i=
ntegers but how many nodes? 2? 1 and some wasted space? None at all?</div><=
div><br></div><div>Some possible container-allocator interface fixes to mak=
e an allocator work reliably here:</div><div>1) allow the container to get =
an "initial" space/size from an allocator, which would usually be nullptr/0=
 but would be _buf/N for stack_alloc and similar allocators</div><div>2) cl=
early define the allocation and growth for vector and similar types so that=
 it's knowable whether stack_alloc&lt;T, N&gt; would result in used space f=
or any size N when automatic growth is used (rather than using reserve)</di=
v><div>3) expose the node type or node size of node-based containers (and h=
ope you don't have multiple node types/sizes anytime you need stack_alloc) =
so the user or allocator can make a large enough buffer for N nodes</div><d=
iv><br></div><div>I do think that using allocators is the right approach fo=
r the standards process over one-off containers with slight variations in b=
ehavior.</div><div><br></div><div>But IMO right now the allocator approach =
has usability gotchas that outweigh the benefit of a custom container with =
well-defined allocation patterns in user code. Forgetting a reserve() call =
- or letting it get out of sync with the stack_alloc size during maintenanc=
e - is just far too easy of a mistake to make.</div></div>

<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_3911_217957608.1422316024686--
------=_Part_3910_384482433.1422316024686--

.