Topic: template < class T, class Alloc = allocator<T>, class


Author: Cleiton Santoia <cleitonsantoia@gmail.com>
Date: Fri, 13 Nov 2015 11:21:41 -0800 (PST)
Raw View
------=_Part_7854_1792009550.1447442501362
Content-Type: multipart/alternative;
 boundary="----=_Part_7855_2032599661.1447442501363"

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

What do you guys think of introduce a new parameter in the vector template,=
=20
taking out the implementation of "grow" method from the it=C2=B4s guts and =
put=20
it on a separated class ?
=20
std::vector<int, std::allocator<int>, std::grow_ratio<1,2>>  g2;  //each=20
overflow, it doubles the size;

std::vector<int, std::allocator<int>, std::grow_fix<5>>          gf5;    //=
=20
each overflow grows 5 elements

std::vector<int, std::allocator<int>, std::grow_scaling< scale<0,10, 1>,=20
scale<11, 100, 2>, scale_greater< 100, grow_ratio<1,3> >>  gcomplex;
     grows one by one from 1 to 10, grows 2 by 2 from 11 to 100 and triples=
=20
it size when it became bigger than 100



using current size and the location of current data ( and probably more=20
information ), it can decide how much allocate

struct grow_algorithm {
   size_t new_size(const T* current_data, size_t current_size) {...}
};


BR
Cleiton


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

<div dir=3D"ltr">What do you guys think of introduce a new parameter in the=
 vector template, taking out the implementation of &quot;grow&quot; method =
from the it=C2=B4s guts and put it on a separated class ?<div>=C2=A0</div><=
div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187=
); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code clas=
s=3D"prettyprint"><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"styl=
ed-by-prettify">vector</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">allocator</span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify">&lt;int&gt;</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><span style=3D"color: rgb(0, 0, 0);">grow_ratio=
&lt;1,2</span>&gt;&gt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">=C2=A0 g</span><font color=3D"#666600"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">2</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">=C2=A0=C2=A0</span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">//each overflow, it doubles the size;<br></span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span></font><div cla=
ss=3D"subprettyprint"><font color=3D"#666600"><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(0, 0, 0);">std</span><span class=3D"styled-by-pre=
ttify">::</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0=
, 0);">vector</span><span class=3D"styled-by-prettify">&lt;</span><span cla=
ss=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">int</span><span =
class=3D"styled-by-prettify">,</span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(0, 0, 0);">=C2=A0std</span><span class=3D"styled-by-pretti=
fy">::</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0=
);">allocator</span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
0, 136, 0);">&lt;int&gt;</span><span class=3D"styled-by-prettify">,</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">=C2=A0std<=
/span><span class=3D"styled-by-prettify">::</span></font><span style=3D"col=
or: rgb(0, 0, 0);">grow_fix</span><font color=3D"#666600"><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(0, 0, 0);">&lt;5</span></font><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0); font-family: =
Arial, Helvetica, sans-serif;">&gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<=
/span><span class=3D"styled-by-prettify" style=3D"font-family: Arial, Helve=
tica, sans-serif; color: rgb(0, 0, 0);">gf5; =C2=A0 =C2=A0// each overflow =
grows 5 elements<br><br></span></div></div><div class=3D"subprettyprint"><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">std</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">::</sp=
an><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">vector=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">&lt;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 1=
36);">int</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102,=
 102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);">=C2=A0std</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(102, 102, 0);">::</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(0, 0, 0);">allocator</span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(0, 136, 0);">&lt;int&gt;</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(102, 102, 0);">,</span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 0);">=C2=A0std</span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(102, 102, 0);">::</span><span style=
=3D"color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif;">grow_s=
caling</span><span class=3D"styled-by-prettify" style=3D"font-family: Arial=
, Helvetica, sans-serif; color: rgb(102, 102, 0);"><span style=3D"color: rg=
b(0, 0, 0);">&lt; scale&lt;0,10, 1&gt;, scale&lt;11, 100, 2&gt;, scale_grea=
ter&lt; 100, grow_ratio&lt;1,3&gt;=C2=A0</span>&gt;&gt;</span><span class=
=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, sans-serif;=
 color: rgb(0, 0, 0);">=C2=A0 gcomplex</span><font color=3D"#666600" style=
=3D"font-family: Arial, Helvetica, sans-serif;"><span class=3D"styled-by-pr=
ettify">;<br>=C2=A0 =C2=A0 =C2=A0grows one by one from 1 to 10, grows 2 by =
2 from 11 to 100 and triples it size when it became bigger than 100<br><br>=
<br></span></font></div><div class=3D"subprettyprint"><font color=3D"#66660=
0"><span class=3D"styled-by-prettify" style=3D"color: rgb(136, 0, 0);"><br>=
</span></font><font color=3D"#666600"><span style=3D"color: #000;" class=3D=
"styled-by-prettify">using current size and the location of current data ( =
and probably more information ), it can decide how much allocate<br><br>str=
uct grow_algorithm {<br>=C2=A0 =C2=A0size_t new_size(const T* current_data,=
 size_t current_size) {...}<br>};</span></font></div></code></div><div><br>=
</div><div><br></div><div>BR</div><div>Cleiton</div><br><br></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_7855_2032599661.1447442501363--
------=_Part_7854_1792009550.1447442501362--

.