Topic: Shrink dynamic arrays with delete[] operator


Author: contact@ncomputers.org
Date: Wed, 15 Oct 2014 10:19:32 -0700 (PDT)
Raw View
------=_Part_396_976999164.1413393572524
Content-Type: text/plain; charset=UTF-8

Shrink dynamic arrays on C++
It is very useful to shrink arrays, which were created using the *new*
operator.

*For example:*

Your code requires a billion of objects of a class to find a solution to a
hard problem. As the code finds a new and better solution, some objects
will become useless. Due to complexity, the code starts to require more
time to process the useful data and find better solutions.

As the code had a billion of useful objects in memory, it required only a
few seconds to find a solution to the problem, because they were easier to
find. When the code searches better solutions, it requires less objects and
more time. For example, when it searches a solution with only one million
of objects, it will delay a week to find a new and better solution to the
problem.

It would be a waste of memory to have 999 millions of useless objects for a
whole week. Just imagine, if every object requires ten bytes, the code will
be wasting 9.99 billions of bytes for a whole week.

Thanks to the community of stackoverflow.com <http://www.stackoverflow.com>,
cplusplus.com <http://www.cplusplus.com> and its contributors, we
considered two possible solutions to shrink arrays:

   - Allocate memory using the *std::malloc* function and shrink the array
   using the *std::realloc* function.
   - Create a *new* array, copy the useful objects and *delete* the old
   arrays.

Both are good solutions.

But we desire a solution, which is oriented to objects, automatically calls
the destructors, is a C++ standard compatible with most memory allocators
and neither moves the useful data nor copies it, due to performance.

   - To use the *std::malloc* and *std::realloc* functions is a solution,
   which requires to overload the *new* and *delete* operators to make it
   oriented to objects.
   - To create a *new* array, copy the useful objects and *delete* the old
   array is a solution, which would be very slow if we shrink the array a
   billion of times.
   - The performance offered by the *std::vector* when shrinking could be
   overcome by own implementations or native arrays
   <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp>
   .

Our suggestion to make arrays shrinkable in a C++ oriented to objects way
is the following:

   - Improve the *delete[]* operator syntax by this way:

   *delete [*objects to delete*]* pointer to array;

   where *delete[*0*]* is equivalent to delete nothing.

Best regards,

http://ncomputers.org
<http://ncomputers.org/content/code.php?src=suggestions/shrink%20arrays%20cpp>

--

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

<div dir=3D"ltr"><h1>Shrink dynamic arrays on C++</h1><br>It is very useful=
 to shrink arrays, which were created using the <b>new</b> operator.<br><br=
>
<b>For example:</b><br><br>
Your code requires a billion of objects of a class to find a solution to a =
hard problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com">stackov=
erflow.com</a>, <a href=3D"http://www.cplusplus.com">cplusplus.com</a> and =
its contributors, we considered two possible solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp">could be overcome by own implementations or native arrays</a>.</li></ul=
>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span class=3D"code"><b><span class=3D"keyword">delete</span> [</b>objects =
to delete<b>]</b> pointer to array;</span><br><br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul><p>=
Best regards,</p><p><a href=3D"http://ncomputers.org/content/code.php?src=
=3Dsuggestions/shrink%20arrays%20cpp">http://ncomputers.org</a></p></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_396_976999164.1413393572524--

.


Author: contact@ncomputers.org
Date: Wed, 15 Oct 2014 10:29:06 -0700 (PDT)
Raw View
------=_Part_367_1440339580.1413394146308
Content-Type: text/plain; charset=UTF-8

Shrink dynamic arrays on C++
It is very useful to shrink arrays, which were created using the *new*
operator.

*For example:*

Your code requires a billion of objects of a class to find a solution to a
hard problem. As the code finds a new and better solution, some objects
will become useless. Due to complexity, the code starts to require more
time to process the useful data and find better solutions.

As the code had a billion of useful objects in memory, it required only a
few seconds to find a solution to the problem, because they were easier to
find. When the code searches better solutions, it requires less objects and
more time. For example, when it searches a solution with only one million
of objects, it will delay a week to find a new and better solution to the
problem.

It would be a waste of memory to have 999 millions of useless objects for a
whole week. Just imagine, if every object requires ten bytes, the code will
be wasting 9.99 billions of bytes for a whole week.

Thanks to the community of stackoverflow.com <http://www.stackoverflow.com>,
cplusplus.com <http://www.cplusplus.com> and its contributors, we
considered two possible solutions to shrink arrays:

   - Allocate memory using the *std::malloc* function and shrink the array
   using the *std::realloc* function.
   - Create a *new* array, copy the useful objects and *delete* the old
   arrays.

Both are good solutions.

But we desire a solution, which is oriented to objects, automatically calls
the destructors, is a C++ standard compatible with most memory allocators
and neither moves the useful data nor copies it, due to performance.

   - To use the *std::malloc* and *std::realloc* functions is a solution,
   which requires to overload the *new* and *delete* operators to make it
   oriented to objects.
   - To create a *new* array, copy the useful objects and *delete* the old
   array is a solution, which would be very slow if we shrink the array a
   billion of times.
   - The performance offered by the *std::vector* when shrinking could be
   overcome by other implementations or native arrays
   <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp>
   .

Our suggestion to make arrays shrinkable in a C++ oriented to objects way
is the following:

   - Improve the *delete[]* operator syntax by this way:

   *delete [*objects to delete*]* pointer to array;

   where *delete[*0*]* is equivalent to delete nothing.

Meanwhile this suggestion or a similar is considered to become a probably
futuristic standard, we wrote the following partial solution to shrink
arrays using an explicit call to an overloaded *delete[]* operator.

*Examples: *Shrinkable arrays vs vectors
<http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp>
| Initialize undefined size arrays
<http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%202.cpp>

Best regards,

http://ncomputers.org
<http://ncomputers.org/content/code.php?src=suggestions/shrink%20arrays%20cpp>

--

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

<div dir=3D"ltr"><h1>Shrink dynamic arrays on C++</h1><br>It is very useful=
 to shrink arrays, which were created using the <b>new</b> operator.<br><br=
>
<b>For example:</b><br><br>
Your code requires a billion of objects of a class to find a solution to a =
hard problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com">stackov=
erflow.com</a>, <a href=3D"http://www.cplusplus.com">cplusplus.com</a> and =
its contributors, we considered two possible solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp">could be overcome by other implementations or native arrays</a>.</li></=
ul>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span class=3D"code"><b><span class=3D"keyword">delete</span> [</b>objects =
to delete<b>]</b> pointer to array;</span><br><br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul>
Meanwhile this suggestion or a similar is considered to become a probably f=
uturistic standard,
we wrote the following partial solution to shrink arrays using an explicit =
call to an overloaded <b>delete[]</b> operator.<br><br>
<b>Examples: </b><a class=3D"left" href=3D"http://ncomputers.org/content/co=
de.php?src=3Dexamples/shrink%20arrays%201.cpp">Shrinkable arrays vs vectors=
</a> |
<a class=3D"right" href=3D"http://ncomputers.org/content/code.php?src=3Dexa=
mples/shrink%20arrays%202.cpp">Initialize undefined size arrays</a><br><br>=
Best regards,<br><br><a href=3D"http://ncomputers.org/content/code.php?src=
=3Dsuggestions/shrink%20arrays%20cpp">http://ncomputers.org</a><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_367_1440339580.1413394146308--

.


Author: contact@ncomputers.org
Date: Wed, 15 Oct 2014 10:36:48 -0700 (PDT)
Raw View
------=_Part_5064_1698326993.1413394608264
Content-Type: text/plain; charset=UTF-8

Shrink dynamic arrays with delete[] operator

It is very useful to shrink arrays, which were created using the *new*
operator.

*For example:*

Your code requires a billion of objects of a class to find a solution to a
hard problem. As the code finds a new and better solution, some objects
will become useless. Due to complexity, the code starts to require more
time to process the useful data and find better solutions.

As the code had a billion of useful objects in memory, it required only a
few seconds to find a solution to the problem, because they were easier to
find. When the code searches better solutions, it requires less objects and
more time. For example, when it searches a solution with only one million
of objects, it will delay a week to find a new and better solution to the
problem.

It would be a waste of memory to have 999 millions of useless objects for a
whole week. Just imagine, if every object requires ten bytes, the code will
be wasting 9.99 billions of bytes for a whole week.

Thanks to the community of stackoverflow.com <http://www.stackoverflow.com>,
cplusplus.com <http://www.cplusplus.com> and its contributors, we
considered two possible solutions to shrink arrays:

   - Allocate memory using the *std::malloc* function and shrink the array
   using the *std::realloc* function.
   - Create a *new* array, copy the useful objects and *delete* the old
   arrays.

Both are good solutions.

But we desire a solution, which is oriented to objects, automatically calls
the destructors, is a C++ standard compatible with most memory allocators
and neither moves the useful data nor copies it, due to performance.

   - To use the *std::malloc* and *std::realloc* functions is a solution,
   which requires to overload the *new* and *delete* operators to make it
   oriented to objects.
   - To create a *new* array, copy the useful objects and *delete* the old
   array is a solution, which would be very slow if we shrink the array a
   billion of times.
   - The performance offered by the *std::vector* when shrinking could be
   overcome by own implementations or native arrays
   <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp>
   .

Our suggestion to make arrays shrinkable in a C++ oriented to objects way
is the following:

   - Improve the *delete[]* operator syntax by this way:

   *delete [*objects to delete*]* pointer to array;

   where *delete[*0*]* is equivalent to delete nothing.

*Examples: *Shrinkable arrays vs vectors
<http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp> Initialize
undefined size arrays
<http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%202.cpp>

/* author: ncomputers.org */
#include<cstdlib>
#include<iostream>
using namespace std;

 void*operator new[](size_t s){
     return malloc(s);
 }
 void operator delete[](void*p){
     free(p);
 }
 void operator delete[](void*p,size_t s){
     //It doesn't support objects with destructor.
     if(realloc(p,s)!=p)throw 0;
 }

 int main(){
     typedef int A;
     A*a=new A[100];
     //Suggested syntax:
     //delete[90]a;
     operator delete[](a,10*sizeof(A));
     delete[]a;
     return 0;
 }

Best regards,

http://ncomputers.org
<http://ncomputers.org/content/code.php?src=suggestions/shrink%20arrays%20cpp>

--

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

<div dir=3D"ltr"><h1>Shrink dynamic arrays with delete[] operator<br></h1><=
br>It is very useful to shrink arrays, which were created using the <b>new<=
/b> operator.<br><br>
<b>For example:</b><br><br>
Your code requires a billion of objects of a class to find a solution to a =
hard problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com">stackov=
erflow.com</a>, <a href=3D"http://www.cplusplus.com">cplusplus.com</a> and =
its contributors, we considered two possible solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp">could be overcome by own implementations or native arrays</a>.</li></ul=
>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span class=3D"code"><b><span class=3D"keyword">delete</span> [</b>objects =
to delete<b>]</b> pointer to array;</span><br><br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul>
<b>Examples: </b><a class=3D"left" href=3D"http://ncomputers.org/content/co=
de.php?src=3Dexamples/shrink%20arrays%201.cpp">Shrinkable arrays vs vectors=
</a>
<a class=3D"right" href=3D"http://ncomputers.org/content/code.php?src=3Dexa=
mples/shrink%20arrays%202.cpp">Initialize undefined size arrays</a><br><br>=
<code><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 2=
50); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1=
px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpr=
ettyprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">/* aut=
hor: ncomputers.org */</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">#include</span><span style=3D"color: #080;" class=3D"styled-by-pretti=
fy">&lt;cstdlib&gt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">#include</span><span style=3D"color: #080;" class=3D"styled-by-prettify"=
>&lt;iostream&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">namespace</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</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;<br>&nbsp;</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">new</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">[](</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">size_t s</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">){</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> malloc</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">s</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><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">delete</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">[](</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">void</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">p</span><span style=3D"color: #660;" class=3D"styled-by-prettify">){</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbs=
p; &nbsp;free</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p</spa=
n><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><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">delete</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">[](</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">void</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">size_t s</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">){</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;</span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">//It doesn't support o=
bjects with destructor.</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">realloc</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">s</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)!=3D</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">p</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">)</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">throw</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">0</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;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;<br>&nb=
sp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> main</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> A</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;A</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">new</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> A</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">100</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">];</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbs=
p;</span><span style=3D"color: #800;" class=3D"styled-by-prettify">//Sugges=
ted syntax:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//delete[90]a;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">delete</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">[](</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">a</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">A</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;" class=3D"styled-by-prettify">delete</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">[]</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span=
></div></code></div><br></code>Best regards,<br><br><a href=3D"http://ncomp=
uters.org/content/code.php?src=3Dsuggestions/shrink%20arrays%20cpp">http://=
ncomputers.org</a><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_5064_1698326993.1413394608264--

.


Author: contact@ncomputers.org
Date: Wed, 15 Oct 2014 10:47:37 -0700 (PDT)
Raw View
------=_Part_337_1946487837.1413395257947
Content-Type: text/plain; charset=UTF-8

Shrink dynamic arrays with delete[] operator

It is very useful to shrink arrays, which were created using the *new*
operator.

*For example:*

A code requires a billion of objects of a class to find a solution to a
hard problem. As the code finds a new and better solution, some objects
will become useless. Due to complexity, the code starts to require more
time to process the useful data and find better solutions.

As the code had a billion of useful objects in memory, it required only a
few seconds to find a solution to the problem, because they were easier to
find. When the code searches better solutions, it requires less objects and
more time. For example, when it searches a solution with only one million
of objects, it will delay a week to find a new and better solution to the
problem.

It would be a waste of memory to have 999 millions of useless objects for a
whole week. Just imagine, if every object requires ten bytes, the code will
be wasting 9.99 billions of bytes for a whole week.

Thanks to the community of stackoverflow.com <http://www.stackoverflow.com>,
cplusplus.com <http://www.cplusplus.com> and its contributors, we
considered two possible solutions to shrink arrays:

   - Allocate memory using the *std::malloc* function and shrink the array
   using the *std::realloc* function.
   - Create a *new* array, copy the useful objects and *delete* the old
   arrays.

Both are good solutions.

But we desire a solution, which is oriented to objects, automatically calls
the destructors, is a C++ standard compatible with most memory allocators
and neither moves the useful data nor copies it, due to performance.

   - To use the *std::malloc* and *std::realloc* functions is a solution,
   which requires to overload the *new* and *delete* operators to make it
   oriented to objects.
   - To create a *new* array, copy the useful objects and *delete* the old
   array is a solution, which would be very slow if we shrink the array a
   billion of times.
   - The performance offered by the *std::vector* when shrinking could be
   overcome by own implementations or native arrays
   <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp>
   .

Our suggestion to make arrays shrinkable in a C++ oriented to objects way
is the following:

   - Improve the *delete[]* operator syntax by this way:

   delete [objects to delete] pointer to array;

   where *delete[*0*]* is equivalent to delete nothing.

We wrote the following partial solution to shrink arrays using an explicit
call to an overloaded *delete[]* operator.

*Examples: *Shrinkable arrays vs vectors |
<http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp> Initialize
undefined size arrays
<http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%202.cpp>

/* author: ncomputers.org */
#include<cstdlib>
#include<iostream>
using namespace std;

 void*operator new[](size_t s){
     return malloc(s);
 }
 void operator delete[](void*p){
     free(p);
 }
 void operator delete[](void*p,size_t s){
     //It doesn't support objects with destructor.
     if(realloc(p,s)!=p)throw 0;
 }

 int main(){
     typedef int A;
     A*a=new A[100];
     //Suggested syntax:
     //delete[90]a;
     operator delete[](a,10*sizeof(A));
     delete[]a;
     return 0;
 }

Best regards,

http://ncomputers.org
<http://ncomputers.org/content/code.php?src=suggestions/shrink%20arrays%20cpp>

--

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

<div dir=3D"ltr"><h1>Shrink dynamic arrays with delete[] operator<br></h1><=
br>It is very useful to shrink arrays, which were created using the <b>new<=
/b> operator.<br><br>
<b>For example:</b><br><br>
A code requires a billion of objects of a class to find a solution to a har=
d problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com">stackov=
erflow.com</a>, <a href=3D"http://www.cplusplus.com">cplusplus.com</a> and =
its contributors, we considered two possible solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp">could be overcome by own implementations or native arrays</a>.</li></ul=
>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span class=3D"code"><span class=3D"keyword">delete</span> [objects to dele=
te] pointer to array;</span><br><br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul>
We wrote the following partial solution to shrink arrays using an explicit =
call to an overloaded <b>delete[]</b> operator.<br><br>
<b>Examples: </b><a class=3D"left" href=3D"http://ncomputers.org/content/co=
de.php?src=3Dexamples/shrink%20arrays%201.cpp">Shrinkable arrays vs vectors=
 |</a>
<a class=3D"right" href=3D"http://ncomputers.org/content/code.php?src=3Dexa=
mples/shrink%20arrays%202.cpp">Initialize undefined size arrays</a><br><br>=
<code><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 2=
50); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1=
px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpr=
ettyprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">/* aut=
hor: ncomputers.org */</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">#include</span><span style=3D"color: #080;" class=3D"styled-by-pretti=
fy">&lt;cstdlib&gt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">#include</span><span style=3D"color: #080;" class=3D"styled-by-prettify"=
>&lt;iostream&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">namespace</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</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;<br>&nbsp;</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">new</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">[](</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">size_t s</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">){</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> malloc</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">s</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><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">delete</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">[](</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">void</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">p</span><span style=3D"color: #660;" class=3D"styled-by-prettify">){</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbs=
p; &nbsp;free</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p</spa=
n><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><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">delete</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">[](</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">void</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">size_t s</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">){</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;</span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">//It doesn't support o=
bjects with destructor.</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">realloc</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">s</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)!=3D</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">p</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">)</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">throw</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">0</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;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;<br>&nb=
sp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> main</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> A</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;A</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">new</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> A</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">100</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">];</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbs=
p;</span><span style=3D"color: #800;" class=3D"styled-by-prettify">//Sugges=
ted syntax:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//delete[90]a;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">delete</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">[](</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">a</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">A</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;" class=3D"styled-by-prettify">delete</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">[]</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span></di=
v></code></div><br>Best regards,<br><br><a href=3D"http://ncomputers.org/co=
ntent/code.php?src=3Dsuggestions/shrink%20arrays%20cpp">http://ncomputers.o=
rg</a><br></code>
</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_337_1946487837.1413395257947--

.


Author: Joel Falcou <joel.falcou@gmail.com>
Date: Wed, 15 Oct 2014 20:15:15 +0200
Raw View
--001a113f4fd60c85f705057a1df7
Content-Type: text/plain; charset=UTF-8

why not using vector and resize or shrink_to_fit ?
handling raw memory using new/delete is usually ill advised in modern c++

2014-10-15 19:47 GMT+02:00 <contact@ncomputers.org>:

> Shrink dynamic arrays with delete[] operator
>
> It is very useful to shrink arrays, which were created using the *new*
> operator.
>
> *For example:*
>
> A code requires a billion of objects of a class to find a solution to a
> hard problem. As the code finds a new and better solution, some objects
> will become useless. Due to complexity, the code starts to require more
> time to process the useful data and find better solutions.
>
> As the code had a billion of useful objects in memory, it required only a
> few seconds to find a solution to the problem, because they were easier to
> find. When the code searches better solutions, it requires less objects and
> more time. For example, when it searches a solution with only one million
> of objects, it will delay a week to find a new and better solution to the
> problem.
>
> It would be a waste of memory to have 999 millions of useless objects for
> a whole week. Just imagine, if every object requires ten bytes, the code
> will be wasting 9.99 billions of bytes for a whole week.
>
> Thanks to the community of stackoverflow.com
> <http://www.stackoverflow.com>, cplusplus.com <http://www.cplusplus.com>
> and its contributors, we considered two possible solutions to shrink
> arrays:
>
>    - Allocate memory using the *std::malloc* function and shrink the
>    array using the *std::realloc* function.
>    - Create a *new* array, copy the useful objects and *delete* the old
>    arrays.
>
> Both are good solutions.
>
> But we desire a solution, which is oriented to objects, automatically
> calls the destructors, is a C++ standard compatible with most memory
> allocators and neither moves the useful data nor copies it, due to
> performance.
>
>    - To use the *std::malloc* and *std::realloc* functions is a solution,
>    which requires to overload the *new* and *delete* operators to make it
>    oriented to objects.
>    - To create a *new* array, copy the useful objects and *delete* the
>    old array is a solution, which would be very slow if we shrink the array a
>    billion of times.
>    - The performance offered by the *std::vector* when shrinking could be
>    overcome by own implementations or native arrays
>    <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp>
>    .
>
> Our suggestion to make arrays shrinkable in a C++ oriented to objects way
> is the following:
>
>    - Improve the *delete[]* operator syntax by this way:
>
>    delete [objects to delete] pointer to array;
>
>    where *delete[*0*]* is equivalent to delete nothing.
>
> We wrote the following partial solution to shrink arrays using an explicit
> call to an overloaded *delete[]* operator.
>
> *Examples: *Shrinkable arrays vs vectors |
> <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp> Initialize
> undefined size arrays
> <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%202.cpp>
>
> /* author: ncomputers.org */
> #include<cstdlib>
> #include<iostream>
> using namespace std;
>
>  void*operator new[](size_t s){
>      return malloc(s);
>  }
>  void operator delete[](void*p){
>      free(p);
>  }
>  void operator delete[](void*p,size_t s){
>      //It doesn't support objects with destructor.
>      if(realloc(p,s)!=p)throw 0;
>  }
>
>  int main(){
>      typedef int A;
>      A*a=new A[100];
>      //Suggested syntax:
>      //delete[90]a;
>      operator delete[](a,10*sizeof(A));
>      delete[]a;
>      return 0;
>  }
>
> Best regards,
>
> http://ncomputers.org
> <http://ncomputers.org/content/code.php?src=suggestions/shrink%20arrays%20cpp>
>
> --
>
> ---
> 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/.

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

<div dir=3D"ltr"><div>why not using vector and resize or shrink_to_fit ?<br=
></div>handling raw memory using new/delete is usually ill advised in moder=
n c++<br></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">20=
14-10-15 19:47 GMT+02:00  <span dir=3D"ltr">&lt;<a href=3D"mailto:contact@n=
computers.org" target=3D"_blank">contact@ncomputers.org</a>&gt;</span>:<br>=
<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"><span class=3D""><h1>Shrink=
 dynamic arrays with delete[] operator<br></h1><br>It is very useful to shr=
ink arrays, which were created using the <b>new</b> operator.<br><br>
<b>For example:</b><br><br></span><span class=3D"">
A code requires a billion of objects of a class to find a solution to a har=
d problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com" target=
=3D"_blank">stackoverflow.com</a>, <a href=3D"http://www.cplusplus.com" tar=
get=3D"_blank">cplusplus.com</a> and its contributors, we considered two po=
ssible solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp" target=3D"_blank">could be overcome by own implementations or native ar=
rays</a>.</li></ul>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span><span>delete</span> [objects to delete] pointer to array;</span><br><=
br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul></s=
pan><span class=3D"">
We wrote the following partial solution to shrink arrays using an explicit =
call to an overloaded <b>delete[]</b> operator.<br><br>
</span><div><div class=3D"h5"><b>Examples: </b><a href=3D"http://ncomputers=
..org/content/code.php?src=3Dexamples/shrink%20arrays%201.cpp" target=3D"_bl=
ank">Shrinkable arrays vs vectors |</a>
<a href=3D"http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20a=
rrays%202.cpp" target=3D"_blank">Initialize undefined size arrays</a><br><b=
r><code><div style=3D"background-color:rgb(250,250,250);border-color:rgb(18=
7,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>=
<div><span style=3D"color:#800">/* author: <a href=3D"http://ncomputers.org=
" target=3D"_blank">ncomputers.org</a> */</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#800">#include</span><span style=3D"color:#=
080">&lt;cstdlib&gt;</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#800">#include</span><span style=3D"color:#080">&lt;iostream&gt;=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">usi=
ng</span><span style=3D"color:#000"> </span><span style=3D"color:#008">name=
space</span><span style=3D"color:#000"> std</span><span style=3D"color:#660=
">;</span><span style=3D"color:#000"><br>=C2=A0<br>=C2=A0</span><span style=
=3D"color:#008">void</span><span style=3D"color:#660">*</span><span style=
=3D"color:#008">operator</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">new</span><span style=3D"color:#660">[](</span><span styl=
e=3D"color:#000">size_t s</span><span style=3D"color:#660">){</span><span s=
tyle=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#00=
8">return</span><span style=3D"color:#000"> malloc</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">s</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"col=
or:#660">}</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D=
"color:#008">void</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">operator</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">delete</span><span style=3D"color:#660">[](</span><span style=
=3D"color:#008">void</span><span style=3D"color:#660">*</span><span style=
=3D"color:#000">p</span><span style=3D"color:#660">){</span><span style=3D"=
color:#000"><br>=C2=A0 =C2=A0 =C2=A0free</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">p</span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#660">}=
</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#00=
8">void</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>operator</span><span style=3D"color:#000"> </span><span style=3D"color:#00=
8">delete</span><span style=3D"color:#660">[](</span><span style=3D"color:#=
008">void</span><span style=3D"color:#660">*</span><span style=3D"color:#00=
0">p</span><span style=3D"color:#660">,</span><span style=3D"color:#000">si=
ze_t s</span><span style=3D"color:#660">){</span><span style=3D"color:#000"=
><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#800">//It doesn&#39;t=
 support objects with destructor.</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">if</span><span style=3D"=
color:#660">(</span><span style=3D"color:#000">realloc</span><span style=3D=
"color:#660">(</span><span style=3D"color:#000">p</span><span style=3D"colo=
r:#660">,</span><span style=3D"color:#000">s</span><span style=3D"color:#66=
0">)!=3D</span><span style=3D"color:#000">p</span><span style=3D"color:#660=
">)</span><span style=3D"color:#008">throw</span><span style=3D"color:#000"=
> </span><span style=3D"color:#066">0</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#660">=
}</span><span style=3D"color:#000"><br>=C2=A0<br>=C2=A0</span><span style=
=3D"color:#008">int</span><span style=3D"color:#000"> main</span><span styl=
e=3D"color:#660">(){</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=
=A0</span><span style=3D"color:#008">typedef</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">int</span><span style=3D"color:#000">=
 A</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 =C2=A0A</span><span style=3D"color:#660">*</span><span style=
=3D"color:#000">a</span><span style=3D"color:#660">=3D</span><span style=3D=
"color:#008">new</span><span style=3D"color:#000"> A</span><span style=3D"c=
olor:#660">[</span><span style=3D"color:#066">100</span><span style=3D"colo=
r:#660">];</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span>=
<span style=3D"color:#800">//Suggested syntax:</span><span style=3D"color:#=
000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#800">//delete[90]=
a;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span st=
yle=3D"color:#008">operator</span><span style=3D"color:#000"> </span><span =
style=3D"color:#008">delete</span><span style=3D"color:#660">[](</span><spa=
n style=3D"color:#000">a</span><span style=3D"color:#660">,</span><span sty=
le=3D"color:#066">10</span><span style=3D"color:#660">*</span><span style=
=3D"color:#008">sizeof</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">A</span><span style=3D"color:#660">));</span><span style=3D=
"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">dele=
te</span><span style=3D"color:#660">[]</span><span style=3D"color:#000">a</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">return</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">0</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br>=C2=A0</span><span style=
=3D"color:#660">}</span><span style=3D"color:#000"> <br></span></div></code=
></div><br>Best regards,<br><br><a href=3D"http://ncomputers.org/content/co=
de.php?src=3Dsuggestions/shrink%20arrays%20cpp" target=3D"_blank">http://nc=
omputers.org</a><br></code>
</div></div></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 />

--001a113f4fd60c85f705057a1df7--

.


Author: contact@ncomputers.org
Date: Wed, 15 Oct 2014 11:30:46 -0700 (PDT)
Raw View
------=_Part_487_748650677.1413397847126
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thank you very much for your time and your answer!

The performance offered by the *std::vector* when shrinking could be=20
> overcome by own implementations or native arrays=20
> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%20=
1.cpp>
> .


It is probably due to: ISO/IEC JTC1/SC22/WG21 N3495=20
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm>

Best regards,

http://ncomputers.org=20

El mi=C3=A9rcoles, 15 de octubre de 2014 13:15:16 UTC-5, Joel Falcou escrib=
i=C3=B3:
>
> why not using vector and resize or shrink_to_fit ?
> handling raw memory using new/delete is usually ill advised in modern c++
>
> 2014-10-15 19:47 GMT+02:00 <con...@ncomputers.org <javascript:>>:
>
>> Shrink dynamic arrays with delete[] operator
>>
>> It is very useful to shrink arrays, which were created using the *new*=
=20
>> operator.
>>
>> *For example:*
>>
>> A code requires a billion of objects of a class to find a solution to a=
=20
>> hard problem. As the code finds a new and better solution, some objects=
=20
>> will become useless. Due to complexity, the code starts to require more=
=20
>> time to process the useful data and find better solutions.
>>
>> As the code had a billion of useful objects in memory, it required only =
a=20
>> few seconds to find a solution to the problem, because they were easier =
to=20
>> find. When the code searches better solutions, it requires less objects =
and=20
>> more time. For example, when it searches a solution with only one millio=
n=20
>> of objects, it will delay a week to find a new and better solution to th=
e=20
>> problem.
>>
>> It would be a waste of memory to have 999 millions of useless objects fo=
r=20
>> a whole week. Just imagine, if every object requires ten bytes, the code=
=20
>> will be wasting 9.99 billions of bytes for a whole week.
>>
>> Thanks to the community of stackoverflow.com=20
>> <http://www.stackoverflow.com>, cplusplus.com <http://www.cplusplus.com>=
=20
>> and its contributors, we considered two possible solutions to shrink=20
>> arrays:=20
>>   =20
>>    - Allocate memory using the *std::malloc* function and shrink the=20
>>    array using the *std::realloc* function.
>>    - Create a *new* array, copy the useful objects and *delete* the old=
=20
>>    arrays.
>>
>> Both are good solutions.
>>
>> But we desire a solution, which is oriented to objects, automatically=20
>> calls the destructors, is a C++ standard compatible with most memory=20
>> allocators and neither moves the useful data nor copies it, due to=20
>> performance.=20
>>   =20
>>    - To use the *std::malloc* and *std::realloc* functions is a=20
>>    solution, which requires to overload the *new* and *delete* operators=
=20
>>    to make it oriented to objects.
>>    - To create a *new* array, copy the useful objects and *delete* the=
=20
>>    old array is a solution, which would be very slow if we shrink the ar=
ray a=20
>>    billion of times.
>>    - The performance offered by the *std::vector* when shrinking could=
=20
>>    be overcome by own implementations or native arrays=20
>>    <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20array=
s%201.cpp>
>>    .
>>
>> Our suggestion to make arrays shrinkable in a C++ oriented to objects wa=
y=20
>> is the following:=20
>>   =20
>>    - Improve the *delete[]* operator syntax by this way:
>>   =20
>>    delete [objects to delete] pointer to array;
>>   =20
>>    where *delete[*0*]* is equivalent to delete nothing.
>>
>> We wrote the following partial solution to shrink arrays using an=20
>> explicit call to an overloaded *delete[]* operator.
>>
>> *Examples: *Shrinkable arrays vs vectors |=20
>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%2=
01.cpp> Initialize=20
>> undefined size arrays=20
>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%2=
02.cpp>
>>
>> /* author: ncomputers.org */
>> #include<cstdlib>
>> #include<iostream>
>> using namespace std;
>> =20
>>  void*operator new[](size_t s){
>>      return malloc(s);
>>  }
>>  void operator delete[](void*p){
>>      free(p);
>>  }
>>  void operator delete[](void*p,size_t s){
>>      //It doesn't support objects with destructor.
>>      if(realloc(p,s)!=3Dp)throw 0;
>>  }
>> =20
>>  int main(){
>>      typedef int A;
>>      A*a=3Dnew A[100];
>>      //Suggested syntax:
>>      //delete[90]a;
>>      operator delete[](a,10*sizeof(A));
>>      delete[]a;
>>      return 0;
>>  }=20
>>
>> Best regards,
>>
>> http://ncomputers.org=20
>> <http://ncomputers.org/content/code.php?src=3Dsuggestions/shrink%20array=
s%20cpp>
>> =20
>> --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at=20
>> 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/.

------=_Part_487_748650677.1413397847126
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thank you very much for your time and your answer!<br><br>=
<blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(=
204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">The performance o=
ffered by the <b>std::vector</b> when shrinking <a href=3D"http://ncomputer=
s.org/content/code.php?src=3Dexamples/shrink%20arrays%201.cpp" target=3D"_b=
lank">could be overcome by own implementations or native arrays</a>.</block=
quote><div><br>It is probably due to: <a href=3D"http://www.open-std.org/jt=
c1/sc22/wg21/docs/papers/2013/n3495.htm">ISO/IEC JTC1/SC22/WG21 N3495 </a><=
br><br>Best regards,<br><br><a href=3D"http://ncomputers.org">http://ncompu=
ters.org</a>&nbsp;<br></div><br>El mi=C3=A9rcoles, 15 de octubre de 2014 13=
:15:16 UTC-5, Joel Falcou escribi=C3=B3:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;"><div dir=3D"ltr"><div>why not using vector and resize or shrink_t=
o_fit ?<br></div>handling raw memory using new/delete is usually ill advise=
d in modern c++<br></div><div><br><div class=3D"gmail_quote">2014-10-15 19:=
47 GMT+02:00  <span dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blan=
k" gdf-obfuscated-mailto=3D"1WOmPMajBNYJ" onmousedown=3D"this.href=3D'javas=
cript:';return true;" onclick=3D"this.href=3D'javascript:';return true;">co=
n...@ncomputers.org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div =
dir=3D"ltr"><span><h1>Shrink dynamic arrays with delete[] operator<br></h1>=
<br>It is very useful to shrink arrays, which were created using the <b>new=
</b> operator.<br><br>
<b>For example:</b><br><br></span><span>
A code requires a billion of objects of a class to find a solution to a har=
d problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com" target=
=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fwww.stackoverflow.com\46sa\75D\46sntz\0751\46usg\75AFQjCNHxis3Moxum=
f61TOKR4A6-hB0lXqQ';return true;" onclick=3D"this.href=3D'http://www.google=
..com/url?q\75http%3A%2F%2Fwww.stackoverflow.com\46sa\75D\46sntz\0751\46usg\=
75AFQjCNHxis3Moxumf61TOKR4A6-hB0lXqQ';return true;">stackoverflow.com</a>, =
<a href=3D"http://www.cplusplus.com" target=3D"_blank" onmousedown=3D"this.=
href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.cplusplus.com\46sa\7=
5D\46sntz\0751\46usg\75AFQjCNFaK0j9ns3fJtK0hIP8DIwVcCj74g';return true;" on=
click=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.cplusp=
lus.com\46sa\75D\46sntz\0751\46usg\75AFQjCNFaK0j9ns3fJtK0hIP8DIwVcCj74g';re=
turn true;">cplusplus.com</a> and its contributors, we considered two possi=
ble solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fsh=
rink%2520arrays%25201.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf0rSm=
9Q5qJoJpYli0fA';return true;" onclick=3D"this.href=3D'http://www.google.com=
/url?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%=
2Fshrink%2520arrays%25201.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf=
0rSm9Q5qJoJpYli0fA';return true;">could be overcome by own implementations =
or native arrays</a>.</li></ul>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span><span>delete</span> [objects to delete] pointer to array;</span><br><=
br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul></s=
pan><span>
We wrote the following partial solution to shrink arrays using an explicit =
call to an overloaded <b>delete[]</b> operator.<br><br>
</span><div><div><b>Examples: </b><a href=3D"http://ncomputers.org/content/=
code.php?src=3Dexamples/shrink%20arrays%201.cpp" target=3D"_blank" onmoused=
own=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncomputers.o=
rg%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fshrink%2520arrays%25201.cpp\46sa=
\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf0rSm9Q5qJoJpYli0fA';return true;" =
onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncompute=
rs.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fshrink%2520arrays%25201.cpp\=
46sa\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf0rSm9Q5qJoJpYli0fA';return tru=
e;">Shrinkable arrays vs vectors |</a>
<a href=3D"http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20a=
rrays%202.cpp" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dex=
amples%2Fshrink%2520arrays%25202.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNHRE=
zi8AEWBBbtOfDy5XjccIwPkfw';return true;" onclick=3D"this.href=3D'http://www=
..google.com/url?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%=
3Dexamples%2Fshrink%2520arrays%25202.cpp\46sa\75D\46sntz\0751\46usg\75AFQjC=
NHREzi8AEWBBbtOfDy5XjccIwPkfw';return true;">Initialize undefined size arra=
ys</a><br><br><code><div style=3D"background-color:rgb(250,250,250);border-=
color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-=
word"><code><div><span style=3D"color:#800">/* author: <a href=3D"http://nc=
omputers.org" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.goog=
le.com/url?q\75http%3A%2F%2Fncomputers.org\46sa\75D\46sntz\0751\46usg\75AFQ=
jCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return true;" onclick=3D"this.href=3D'http=
://www.google.com/url?q\75http%3A%2F%2Fncomputers.org\46sa\75D\46sntz\0751\=
46usg\75AFQjCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return true;">ncomputers.org</a=
> */</span><span style=3D"color:#000"><br></span><span style=3D"color:#800"=
>#include</span><span style=3D"color:#080">&lt;cstdlib&gt;</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#800">#include</span><span=
 style=3D"color:#080">&lt;iostream&gt;</span><span style=3D"color:#000"><br=
></span><span style=3D"color:#008">using</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">namespace</span><span style=3D"color:#000=
"> std</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
<br>&nbsp;<br>&nbsp;</span><span style=3D"color:#008">void</span><span styl=
e=3D"color:#660">*</span><span style=3D"color:#008">operator</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">new</span><span style=
=3D"color:#660">[](</span><span style=3D"color:#000">size_t s</span><span s=
tyle=3D"color:#660">){</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &=
nbsp;</span><span style=3D"color:#008">return</span><span style=3D"color:#0=
00"> malloc</span><span style=3D"color:#660">(</span><span style=3D"color:#=
000">s</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
><br>&nbsp;</span><span style=3D"color:#660">}</span><span style=3D"color:#=
000"><br>&nbsp;</span><span style=3D"color:#008">void</span><span style=3D"=
color:#000"> </span><span style=3D"color:#008">operator</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">delete</span><span style=
=3D"color:#660">[](</span><span style=3D"color:#008">void</span><span style=
=3D"color:#660">*</span><span style=3D"color:#000">p</span><span style=3D"c=
olor:#660">){</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;free=
</span><span style=3D"color:#660">(</span><span style=3D"color:#000">p</spa=
n><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>&nbsp;=
</span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>&n=
bsp;</span><span style=3D"color:#008">void</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">operator</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">delete</span><span style=3D"color:#66=
0">[](</span><span style=3D"color:#008">void</span><span style=3D"color:#66=
0">*</span><span style=3D"color:#000">p</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000">size_t s</span><span style=3D"color:#660">=
){</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><span st=
yle=3D"color:#800">//It doesn't support objects with destructor.</span><spa=
n style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color:=
#008">if</span><span style=3D"color:#660">(</span><span style=3D"color:#000=
">realloc</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
0">p</span><span style=3D"color:#660">,</span><span style=3D"color:#000">s<=
/span><span style=3D"color:#660">)!=3D</span><span style=3D"color:#000">p</=
span><span style=3D"color:#660">)</span><span style=3D"color:#008">throw</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#066">0</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"><br>&nbsp;</sp=
an><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>&nbsp;=
<br>&nbsp;</span><span style=3D"color:#008">int</span><span style=3D"color:=
#000"> main</span><span style=3D"color:#660">(){</span><span style=3D"color=
:#000"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color:#008">typedef</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">int</span=
><span style=3D"color:#000"> A</span><span style=3D"color:#660">;</span><sp=
an style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;A</span><span style=3D"colo=
r:#660">*</span><span style=3D"color:#000">a</span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#008">new</span><span style=3D"color:#000=
"> A</span><span style=3D"color:#660">[</span><span style=3D"color:#066">10=
0</span><span style=3D"color:#660">];</span><span style=3D"color:#000"><br>=
&nbsp; &nbsp; &nbsp;</span><span style=3D"color:#800">//Suggested syntax:</=
span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><span style=
=3D"color:#800">//delete[90]a;</span><span style=3D"color:#000"><br>&nbsp; =
&nbsp; &nbsp;</span><span style=3D"color:#008">operator</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">delete</span><span style=
=3D"color:#660">[](</span><span style=3D"color:#000">a</span><span style=3D=
"color:#660">,</span><span style=3D"color:#066">10</span><span style=3D"col=
or:#660">*</span><span style=3D"color:#008">sizeof</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">A</span><span style=3D"color:#6=
60">));</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><sp=
an style=3D"color:#008">delete</span><span style=3D"color:#660">[]</span><s=
pan style=3D"color:#000">a</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color:#00=
8">return</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">0</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><b=
r>&nbsp;</span><span style=3D"color:#660">}</span><span style=3D"color:#000=
"> <br></span></div></code></div><br>Best regards,<br><br><a href=3D"http:/=
/ncomputers.org/content/code.php?src=3Dsuggestions/shrink%20arrays%20cpp" t=
arget=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75=
http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dsuggestions%2Fshri=
nk%2520arrays%2520cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNHEBX0WCIGBqp1zLCaV=
5pohm9B36g';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dsuggestions%2=
Fshrink%2520arrays%2520cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNHEBX0WCIGBqp1=
zLCaV5pohm9B36g';return true;">http://ncomputers.org</a><br></code>
</div></div></div><div><div>

<p></p>

-- <br>
<br>
--- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
1WOmPMajBNYJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"1WOmPMajBNYJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></div></blockquote></div><br></div>
</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_487_748650677.1413397847126--

.


Author: Joel Falcou <joel.falcou@gmail.com>
Date: Wed, 15 Oct 2014 20:39:20 +0200
Raw View
--20cf304273163b76ff05057a7398
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

for such a benchmark to be valid it has to be done with a given replicable
protocol. If not it's meaning less. So do you have a reproductible
benchmark anybody can have a look at.
Abstarction penalty on std container is usually very low so I guess your
benchmark is biased.

2014-10-15 20:30 GMT+02:00 <contact@ncomputers.org>:

> Thank you very much for your time and your answer!
>
> The performance offered by the *std::vector* when shrinking could be
>> overcome by own implementations or native arrays
>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%2=
01.cpp>
>> .
>
>
> It is probably due to: ISO/IEC JTC1/SC22/WG21 N3495
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm>
>
> Best regards,
>
> http://ncomputers.org
>
> El mi=C3=A9rcoles, 15 de octubre de 2014 13:15:16 UTC-5, Joel Falcou escr=
ibi=C3=B3:
>>
>> why not using vector and resize or shrink_to_fit ?
>> handling raw memory using new/delete is usually ill advised in modern c+=
+
>>
>> 2014-10-15 19:47 GMT+02:00 <con...@ncomputers.org>:
>>
>>> Shrink dynamic arrays with delete[] operator
>>>
>>> It is very useful to shrink arrays, which were created using the *new*
>>> operator.
>>>
>>> *For example:*
>>>
>>> A code requires a billion of objects of a class to find a solution to a
>>> hard problem. As the code finds a new and better solution, some objects
>>> will become useless. Due to complexity, the code starts to require more
>>> time to process the useful data and find better solutions.
>>>
>>> As the code had a billion of useful objects in memory, it required only
>>> a few seconds to find a solution to the problem, because they were easi=
er
>>> to find. When the code searches better solutions, it requires less obje=
cts
>>> and more time. For example, when it searches a solution with only one
>>> million of objects, it will delay a week to find a new and better solut=
ion
>>> to the problem.
>>>
>>> It would be a waste of memory to have 999 millions of useless objects
>>> for a whole week. Just imagine, if every object requires ten bytes, the
>>> code will be wasting 9.99 billions of bytes for a whole week.
>>>
>>> Thanks to the community of stackoverflow.com
>>> <http://www.stackoverflow.com>, cplusplus.com <http://www.cplusplus.com=
>
>>> and its contributors, we considered two possible solutions to shrink
>>> arrays:
>>>
>>>    - Allocate memory using the *std::malloc* function and shrink the
>>>    array using the *std::realloc* function.
>>>    - Create a *new* array, copy the useful objects and *delete* the old
>>>    arrays.
>>>
>>> Both are good solutions.
>>>
>>> But we desire a solution, which is oriented to objects, automatically
>>> calls the destructors, is a C++ standard compatible with most memory
>>> allocators and neither moves the useful data nor copies it, due to
>>> performance.
>>>
>>>    - To use the *std::malloc* and *std::realloc* functions is a
>>>    solution, which requires to overload the *new* and *delete*
>>>    operators to make it oriented to objects.
>>>    - To create a *new* array, copy the useful objects and *delete* the
>>>    old array is a solution, which would be very slow if we shrink the a=
rray a
>>>    billion of times.
>>>    - The performance offered by the *std::vector* when shrinking could
>>>    be overcome by own implementations or native arrays
>>>    <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arra=
ys%201.cpp>
>>>    .
>>>
>>> Our suggestion to make arrays shrinkable in a C++ oriented to objects
>>> way is the following:
>>>
>>>    - Improve the *delete[]* operator syntax by this way:
>>>
>>>    delete [objects to delete] pointer to array;
>>>
>>>    where *delete[*0*]* is equivalent to delete nothing.
>>>
>>> We wrote the following partial solution to shrink arrays using an
>>> explicit call to an overloaded *delete[]* operator.
>>>
>>> *Examples: *Shrinkable arrays vs vectors |
>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%=
201.cpp> Initialize
>>> undefined size arrays
>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%=
202.cpp>
>>>
>>> /* author: ncomputers.org */
>>> #include<cstdlib>
>>> #include<iostream>
>>> using namespace std;
>>>
>>>  void*operator new[](size_t s){
>>>      return malloc(s);
>>>  }
>>>  void operator delete[](void*p){
>>>      free(p);
>>>  }
>>>  void operator delete[](void*p,size_t s){
>>>      //It doesn't support objects with destructor.
>>>      if(realloc(p,s)!=3Dp)throw 0;
>>>  }
>>>
>>>  int main(){
>>>      typedef int A;
>>>      A*a=3Dnew A[100];
>>>      //Suggested syntax:
>>>      //delete[90]a;
>>>      operator delete[](a,10*sizeof(A));
>>>      delete[]a;
>>>      return 0;
>>>  }
>>>
>>> Best regards,
>>>
>>> http://ncomputers.org
>>> <http://ncomputers.org/content/code.php?src=3Dsuggestions/shrink%20arra=
ys%20cpp>
>>>
>>> --
>>>
>>> ---
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@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/.
>

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

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

<div dir=3D"ltr"><div>for such a benchmark to be valid it has to be done wi=
th a given replicable protocol. If not it&#39;s meaning less. So do you hav=
e a reproductible benchmark anybody can have a look at. <br></div>Abstarcti=
on penalty on std container is usually very low so I guess your benchmark i=
s biased.<br></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote=
">2014-10-15 20:30 GMT+02:00  <span dir=3D"ltr">&lt;<a href=3D"mailto:conta=
ct@ncomputers.org" target=3D"_blank">contact@ncomputers.org</a>&gt;</span>:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Thank you very much for=
 your time and your answer!<span class=3D""><br><br><blockquote style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:=
1ex" class=3D"gmail_quote">The performance offered by the <b>std::vector</b=
> when shrinking <a href=3D"http://ncomputers.org/content/code.php?src=3Dex=
amples/shrink%20arrays%201.cpp" target=3D"_blank">could be overcome by own =
implementations or native arrays</a>.</blockquote></span><div><br>It is pro=
bably due to: <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers=
/2013/n3495.htm" target=3D"_blank">ISO/IEC JTC1/SC22/WG21 N3495 </a><br><br=
>Best regards,<br><br><a href=3D"http://ncomputers.org" target=3D"_blank">h=
ttp://ncomputers.org</a>=C2=A0<br></div><br>El mi=C3=A9rcoles, 15 de octubr=
e de 2014 13:15:16 UTC-5, Joel Falcou escribi=C3=B3:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><span class=3D""><div dir=3D"ltr"><div>why not using vecto=
r and resize or shrink_to_fit ?<br></div>handling raw memory using new/dele=
te is usually ill advised in modern c++<br></div></span><div><br><div class=
=3D"gmail_quote">2014-10-15 19:47 GMT+02:00  <span dir=3D"ltr">&lt;<a>con..=
..@ncomputers.org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><di=
v class=3D"h5"><div dir=3D"ltr"><span><h1>Shrink dynamic arrays with delete=
[] operator<br></h1><br>It is very useful to shrink arrays, which were crea=
ted using the <b>new</b> operator.<br><br>
<b>For example:</b><br><br></span><span>
A code requires a billion of objects of a class to find a solution to a har=
d problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com" target=
=3D"_blank">stackoverflow.com</a>, <a href=3D"http://www.cplusplus.com" tar=
get=3D"_blank">cplusplus.com</a> and its contributors, we considered two po=
ssible solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp" target=3D"_blank">could be overcome by own implementations or native ar=
rays</a>.</li></ul>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span><span>delete</span> [objects to delete] pointer to array;</span><br><=
br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul></s=
pan><span>
We wrote the following partial solution to shrink arrays using an explicit =
call to an overloaded <b>delete[]</b> operator.<br><br>
</span><div><div><b>Examples: </b><a href=3D"http://ncomputers.org/content/=
code.php?src=3Dexamples/shrink%20arrays%201.cpp" target=3D"_blank">Shrinkab=
le arrays vs vectors |</a>
<a href=3D"http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20a=
rrays%202.cpp" target=3D"_blank">Initialize undefined size arrays</a><br><b=
r><code><div style=3D"background-color:rgb(250,250,250);border-color:rgb(18=
7,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>=
<div><span style=3D"color:#800">/* author: <a href=3D"http://ncomputers.org=
" target=3D"_blank">ncomputers.org</a> */</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#800">#include</span><span style=3D"color:#=
080">&lt;cstdlib&gt;</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#800">#include</span><span style=3D"color:#080">&lt;iostream&gt;=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">usi=
ng</span><span style=3D"color:#000"> </span><span style=3D"color:#008">name=
space</span><span style=3D"color:#000"> std</span><span style=3D"color:#660=
">;</span><span style=3D"color:#000"><br>=C2=A0<br>=C2=A0</span><span style=
=3D"color:#008">void</span><span style=3D"color:#660">*</span><span style=
=3D"color:#008">operator</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">new</span><span style=3D"color:#660">[](</span><span styl=
e=3D"color:#000">size_t s</span><span style=3D"color:#660">){</span><span s=
tyle=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#00=
8">return</span><span style=3D"color:#000"> malloc</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">s</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"col=
or:#660">}</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D=
"color:#008">void</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">operator</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">delete</span><span style=3D"color:#660">[](</span><span style=
=3D"color:#008">void</span><span style=3D"color:#660">*</span><span style=
=3D"color:#000">p</span><span style=3D"color:#660">){</span><span style=3D"=
color:#000"><br>=C2=A0 =C2=A0 =C2=A0free</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">p</span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#660">}=
</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#00=
8">void</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>operator</span><span style=3D"color:#000"> </span><span style=3D"color:#00=
8">delete</span><span style=3D"color:#660">[](</span><span style=3D"color:#=
008">void</span><span style=3D"color:#660">*</span><span style=3D"color:#00=
0">p</span><span style=3D"color:#660">,</span><span style=3D"color:#000">si=
ze_t s</span><span style=3D"color:#660">){</span><span style=3D"color:#000"=
><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#800">//It doesn&#39;t=
 support objects with destructor.</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">if</span><span style=3D"=
color:#660">(</span><span style=3D"color:#000">realloc</span><span style=3D=
"color:#660">(</span><span style=3D"color:#000">p</span><span style=3D"colo=
r:#660">,</span><span style=3D"color:#000">s</span><span style=3D"color:#66=
0">)!=3D</span><span style=3D"color:#000">p</span><span style=3D"color:#660=
">)</span><span style=3D"color:#008">throw</span><span style=3D"color:#000"=
> </span><span style=3D"color:#066">0</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#660">=
}</span><span style=3D"color:#000"><br>=C2=A0<br>=C2=A0</span><span style=
=3D"color:#008">int</span><span style=3D"color:#000"> main</span><span styl=
e=3D"color:#660">(){</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=
=A0</span><span style=3D"color:#008">typedef</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">int</span><span style=3D"color:#000">=
 A</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 =C2=A0A</span><span style=3D"color:#660">*</span><span style=
=3D"color:#000">a</span><span style=3D"color:#660">=3D</span><span style=3D=
"color:#008">new</span><span style=3D"color:#000"> A</span><span style=3D"c=
olor:#660">[</span><span style=3D"color:#066">100</span><span style=3D"colo=
r:#660">];</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span>=
<span style=3D"color:#800">//Suggested syntax:</span><span style=3D"color:#=
000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#800">//delete[90]=
a;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span st=
yle=3D"color:#008">operator</span><span style=3D"color:#000"> </span><span =
style=3D"color:#008">delete</span><span style=3D"color:#660">[](</span><spa=
n style=3D"color:#000">a</span><span style=3D"color:#660">,</span><span sty=
le=3D"color:#066">10</span><span style=3D"color:#660">*</span><span style=
=3D"color:#008">sizeof</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">A</span><span style=3D"color:#660">));</span><span style=3D=
"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">dele=
te</span><span style=3D"color:#660">[]</span><span style=3D"color:#000">a</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">return</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">0</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br>=C2=A0</span><span style=
=3D"color:#660">}</span><span style=3D"color:#000"> <br></span></div></code=
></div><br>Best regards,<br><br><a href=3D"http://ncomputers.org/content/co=
de.php?src=3Dsuggestions/shrink%20arrays%20cpp" target=3D"_blank">http://nc=
omputers.org</a><br></code>
</div></div></div></div></div><div><div><div><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></div></div>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<span clas=
s=3D""><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/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</span></div></div></blockquote></div><br></div>
</blockquote></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 />

--20cf304273163b76ff05057a7398--

.


Author: Joel Falcou <joel.falcou@gmail.com>
Date: Wed, 15 Oct 2014 20:41:34 +0200
Raw View
--20cf30427316333d0c05057a7b34
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

it's in fact clearly biased as your timing on vector tim both the
allcoation of the vector and of its contents ... Why don't you just create
vector on the stack instaed of by using new ??

2014-10-15 20:39 GMT+02:00 Joel Falcou <joel.falcou@gmail.com>:

> for such a benchmark to be valid it has to be done with a given replicabl=
e
> protocol. If not it's meaning less. So do you have a reproductible
> benchmark anybody can have a look at.
> Abstarction penalty on std container is usually very low so I guess your
> benchmark is biased.
>
> 2014-10-15 20:30 GMT+02:00 <contact@ncomputers.org>:
>
> Thank you very much for your time and your answer!
>>
>> The performance offered by the *std::vector* when shrinking could be
>>> overcome by own implementations or native arrays
>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%=
201.cpp>
>>> .
>>
>>
>> It is probably due to: ISO/IEC JTC1/SC22/WG21 N3495
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm>
>>
>> Best regards,
>>
>> http://ncomputers.org
>>
>> El mi=C3=A9rcoles, 15 de octubre de 2014 13:15:16 UTC-5, Joel Falcou esc=
ribi=C3=B3:
>>>
>>> why not using vector and resize or shrink_to_fit ?
>>> handling raw memory using new/delete is usually ill advised in modern c=
++
>>>
>>> 2014-10-15 19:47 GMT+02:00 <con...@ncomputers.org>:
>>>
>>>> Shrink dynamic arrays with delete[] operator
>>>>
>>>> It is very useful to shrink arrays, which were created using the *new*
>>>> operator.
>>>>
>>>> *For example:*
>>>>
>>>> A code requires a billion of objects of a class to find a solution to =
a
>>>> hard problem. As the code finds a new and better solution, some object=
s
>>>> will become useless. Due to complexity, the code starts to require mor=
e
>>>> time to process the useful data and find better solutions.
>>>>
>>>> As the code had a billion of useful objects in memory, it required onl=
y
>>>> a few seconds to find a solution to the problem, because they were eas=
ier
>>>> to find. When the code searches better solutions, it requires less obj=
ects
>>>> and more time. For example, when it searches a solution with only one
>>>> million of objects, it will delay a week to find a new and better solu=
tion
>>>> to the problem.
>>>>
>>>> It would be a waste of memory to have 999 millions of useless objects
>>>> for a whole week. Just imagine, if every object requires ten bytes, th=
e
>>>> code will be wasting 9.99 billions of bytes for a whole week.
>>>>
>>>> Thanks to the community of stackoverflow.com
>>>> <http://www.stackoverflow.com>, cplusplus.com
>>>> <http://www.cplusplus.com> and its contributors, we considered two
>>>> possible solutions to shrink arrays:
>>>>
>>>>    - Allocate memory using the *std::malloc* function and shrink the
>>>>    array using the *std::realloc* function.
>>>>    - Create a *new* array, copy the useful objects and *delete* the
>>>>    old arrays.
>>>>
>>>> Both are good solutions.
>>>>
>>>> But we desire a solution, which is oriented to objects, automatically
>>>> calls the destructors, is a C++ standard compatible with most memory
>>>> allocators and neither moves the useful data nor copies it, due to
>>>> performance.
>>>>
>>>>    - To use the *std::malloc* and *std::realloc* functions is a
>>>>    solution, which requires to overload the *new* and *delete*
>>>>    operators to make it oriented to objects.
>>>>    - To create a *new* array, copy the useful objects and *delete* the
>>>>    old array is a solution, which would be very slow if we shrink the =
array a
>>>>    billion of times.
>>>>    - The performance offered by the *std::vector* when shrinking could
>>>>    be overcome by own implementations or native arrays
>>>>    <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arr=
ays%201.cpp>
>>>>    .
>>>>
>>>> Our suggestion to make arrays shrinkable in a C++ oriented to objects
>>>> way is the following:
>>>>
>>>>    - Improve the *delete[]* operator syntax by this way:
>>>>
>>>>    delete [objects to delete] pointer to array;
>>>>
>>>>    where *delete[*0*]* is equivalent to delete nothing.
>>>>
>>>> We wrote the following partial solution to shrink arrays using an
>>>> explicit call to an overloaded *delete[]* operator.
>>>>
>>>> *Examples: *Shrinkable arrays vs vectors |
>>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays=
%201.cpp> Initialize
>>>> undefined size arrays
>>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays=
%202.cpp>
>>>>
>>>> /* author: ncomputers.org */
>>>> #include<cstdlib>
>>>> #include<iostream>
>>>> using namespace std;
>>>>
>>>>  void*operator new[](size_t s){
>>>>      return malloc(s);
>>>>  }
>>>>  void operator delete[](void*p){
>>>>      free(p);
>>>>  }
>>>>  void operator delete[](void*p,size_t s){
>>>>      //It doesn't support objects with destructor.
>>>>      if(realloc(p,s)!=3Dp)throw 0;
>>>>  }
>>>>
>>>>  int main(){
>>>>      typedef int A;
>>>>      A*a=3Dnew A[100];
>>>>      //Suggested syntax:
>>>>      //delete[90]a;
>>>>      operator delete[](a,10*sizeof(A));
>>>>      delete[]a;
>>>>      return 0;
>>>>  }
>>>>
>>>> Best regards,
>>>>
>>>> http://ncomputers.org
>>>> <http://ncomputers.org/content/code.php?src=3Dsuggestions/shrink%20arr=
ays%20cpp>
>>>>
>>>> --
>>>>
>>>> ---
>>>> 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-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@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 Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/.

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

<div dir=3D"ltr">it&#39;s in fact clearly biased as your timing on vector t=
im both the allcoation of the vector and of its contents ... Why don&#39;t =
you just create vector on the stack instaed of by using new ??<br></div><di=
v class=3D"gmail_extra"><br><div class=3D"gmail_quote">2014-10-15 20:39 GMT=
+02:00 Joel Falcou <span dir=3D"ltr">&lt;<a href=3D"mailto:joel.falcou@gmai=
l.com" target=3D"_blank">joel.falcou@gmail.com</a>&gt;</span>:<br><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex"><div dir=3D"ltr"><div>for such a benchmark to be vali=
d it has to be done with a given replicable protocol. If not it&#39;s meani=
ng less. So do you have a reproductible benchmark anybody can have a look a=
t. <br></div>Abstarction penalty on std container is usually very low so I =
guess your benchmark is biased.<br></div><div class=3D"gmail_extra"><br><di=
v class=3D"gmail_quote">2014-10-15 20:30 GMT+02:00  <span dir=3D"ltr">&lt;<=
a href=3D"mailto:contact@ncomputers.org" target=3D"_blank">contact@ncompute=
rs.org</a>&gt;</span>:<div><div class=3D"h5"><br><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr">Thank you very much for your time and your answer!<sp=
an><br><br><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px so=
lid rgb(204,204,204);padding-left:1ex" class=3D"gmail_quote">The performanc=
e offered by the <b>std::vector</b> when shrinking <a href=3D"http://ncompu=
ters.org/content/code.php?src=3Dexamples/shrink%20arrays%201.cpp" target=3D=
"_blank">could be overcome by own implementations or native arrays</a>.</bl=
ockquote></span><div><br>It is probably due to: <a href=3D"http://www.open-=
std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm" target=3D"_blank">ISO/IE=
C JTC1/SC22/WG21 N3495 </a><br><br>Best regards,<br><br><a href=3D"http://n=
computers.org" target=3D"_blank">http://ncomputers.org</a>=C2=A0<br></div><=
br>El mi=C3=A9rcoles, 15 de octubre de 2014 13:15:16 UTC-5, Joel Falcou esc=
ribi=C3=B3:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:=
0.8ex;border-left:1px #ccc solid;padding-left:1ex"><span><div dir=3D"ltr"><=
div>why not using vector and resize or shrink_to_fit ?<br></div>handling ra=
w memory using new/delete is usually ill advised in modern c++<br></div></s=
pan><div><br><div class=3D"gmail_quote">2014-10-15 19:47 GMT+02:00  <span d=
ir=3D"ltr">&lt;<a>con...@ncomputers.org</a>&gt;</span>:<br><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div><div><div dir=3D"ltr"><span><h1>Shrink dynamic arrays w=
ith delete[] operator<br></h1><br>It is very useful to shrink arrays, which=
 were created using the <b>new</b> operator.<br><br>
<b>For example:</b><br><br></span><span>
A code requires a billion of objects of a class to find a solution to a har=
d problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com" target=
=3D"_blank">stackoverflow.com</a>, <a href=3D"http://www.cplusplus.com" tar=
get=3D"_blank">cplusplus.com</a> and its contributors, we considered two po=
ssible solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp" target=3D"_blank">could be overcome by own implementations or native ar=
rays</a>.</li></ul>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span><span>delete</span> [objects to delete] pointer to array;</span><br><=
br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul></s=
pan><span>
We wrote the following partial solution to shrink arrays using an explicit =
call to an overloaded <b>delete[]</b> operator.<br><br>
</span><div><div><b>Examples: </b><a href=3D"http://ncomputers.org/content/=
code.php?src=3Dexamples/shrink%20arrays%201.cpp" target=3D"_blank">Shrinkab=
le arrays vs vectors |</a>
<a href=3D"http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20a=
rrays%202.cpp" target=3D"_blank">Initialize undefined size arrays</a><br><b=
r><code><div style=3D"background-color:rgb(250,250,250);border-color:rgb(18=
7,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>=
<div><span style=3D"color:#800">/* author: <a href=3D"http://ncomputers.org=
" target=3D"_blank">ncomputers.org</a> */</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#800">#include</span><span style=3D"color:#=
080">&lt;cstdlib&gt;</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#800">#include</span><span style=3D"color:#080">&lt;iostream&gt;=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">usi=
ng</span><span style=3D"color:#000"> </span><span style=3D"color:#008">name=
space</span><span style=3D"color:#000"> std</span><span style=3D"color:#660=
">;</span><span style=3D"color:#000"><br>=C2=A0<br>=C2=A0</span><span style=
=3D"color:#008">void</span><span style=3D"color:#660">*</span><span style=
=3D"color:#008">operator</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">new</span><span style=3D"color:#660">[](</span><span styl=
e=3D"color:#000">size_t s</span><span style=3D"color:#660">){</span><span s=
tyle=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#00=
8">return</span><span style=3D"color:#000"> malloc</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">s</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"col=
or:#660">}</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D=
"color:#008">void</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">operator</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">delete</span><span style=3D"color:#660">[](</span><span style=
=3D"color:#008">void</span><span style=3D"color:#660">*</span><span style=
=3D"color:#000">p</span><span style=3D"color:#660">){</span><span style=3D"=
color:#000"><br>=C2=A0 =C2=A0 =C2=A0free</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">p</span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#660">}=
</span><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#00=
8">void</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>operator</span><span style=3D"color:#000"> </span><span style=3D"color:#00=
8">delete</span><span style=3D"color:#660">[](</span><span style=3D"color:#=
008">void</span><span style=3D"color:#660">*</span><span style=3D"color:#00=
0">p</span><span style=3D"color:#660">,</span><span style=3D"color:#000">si=
ze_t s</span><span style=3D"color:#660">){</span><span style=3D"color:#000"=
><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#800">//It doesn&#39;t=
 support objects with destructor.</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">if</span><span style=3D"=
color:#660">(</span><span style=3D"color:#000">realloc</span><span style=3D=
"color:#660">(</span><span style=3D"color:#000">p</span><span style=3D"colo=
r:#660">,</span><span style=3D"color:#000">s</span><span style=3D"color:#66=
0">)!=3D</span><span style=3D"color:#000">p</span><span style=3D"color:#660=
">)</span><span style=3D"color:#008">throw</span><span style=3D"color:#000"=
> </span><span style=3D"color:#066">0</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#660">=
}</span><span style=3D"color:#000"><br>=C2=A0<br>=C2=A0</span><span style=
=3D"color:#008">int</span><span style=3D"color:#000"> main</span><span styl=
e=3D"color:#660">(){</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=
=A0</span><span style=3D"color:#008">typedef</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">int</span><span style=3D"color:#000">=
 A</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 =C2=A0A</span><span style=3D"color:#660">*</span><span style=
=3D"color:#000">a</span><span style=3D"color:#660">=3D</span><span style=3D=
"color:#008">new</span><span style=3D"color:#000"> A</span><span style=3D"c=
olor:#660">[</span><span style=3D"color:#066">100</span><span style=3D"colo=
r:#660">];</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span>=
<span style=3D"color:#800">//Suggested syntax:</span><span style=3D"color:#=
000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#800">//delete[90]=
a;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span st=
yle=3D"color:#008">operator</span><span style=3D"color:#000"> </span><span =
style=3D"color:#008">delete</span><span style=3D"color:#660">[](</span><spa=
n style=3D"color:#000">a</span><span style=3D"color:#660">,</span><span sty=
le=3D"color:#066">10</span><span style=3D"color:#660">*</span><span style=
=3D"color:#008">sizeof</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">A</span><span style=3D"color:#660">));</span><span style=3D=
"color:#000"><br>=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">dele=
te</span><span style=3D"color:#660">[]</span><span style=3D"color:#000">a</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0</span><span style=3D"color:#008">return</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">0</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br>=C2=A0</span><span style=
=3D"color:#660">}</span><span style=3D"color:#000"> <br></span></div></code=
></div><br>Best regards,<br><br><a href=3D"http://ncomputers.org/content/co=
de.php?src=3Dsuggestions/shrink%20arrays%20cpp" target=3D"_blank">http://nc=
omputers.org</a><br></code>
</div></div></div></div></div><div><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></div></div>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<span><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/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</span></div></div></blockquote></div><br></div>
</blockquote></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" 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></div></div><br></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 />

--20cf30427316333d0c05057a7b34--

.


Author: Bo Pesson <bop@gmb.dk>
Date: Wed, 15 Oct 2014 20:45:10 +0200
Raw View
On 2014-10-15 19:29, contact@ncomputers.org wrote:
>
>   Shrink dynamic arrays on C++
>
>
> It is very useful to shrink arrays, which were created using the *new*
> operator.
>
> *For example:*
>
> Your code requires a billion of objects of a class to find a solution to
> a hard problem. As the code finds a new and better solution, some
> objects will become useless. Due to complexity, the code starts to
> require more time to process the useful data and find better solutions.
>
> As the code had a billion of useful objects in memory, it required only
> a few seconds to find a solution to the problem, because they were
> easier to find. When the code searches better solutions, it requires
> less objects and more time. For example, when it searches a solution
> with only one million of objects, it will delay a week to find a new and
> better solution to the problem.
>
> It would be a waste of memory to have 999 millions of useless objects
> for a whole week. Just imagine, if every object requires ten bytes, the
> code will be wasting 9.99 billions of bytes for a whole week.
>
> Thanks to the community of stackoverflow.com
> <http://www.stackoverflow.com>, cplusplus.com <http://www.cplusplus.com>
> and its contributors, we considered two possible solutions to shrink
> arrays:
>
>   * Allocate memory using the *std::malloc* function and shrink the
>     array using the *std::realloc* function.
>   * Create a *new* array, copy the useful objects and *delete* the old
>     arrays.
>
> Both are good solutions.
>
> But we desire a solution, which is oriented to objects, automatically
> calls the destructors, is a C++ standard compatible with most memory
> allocators and neither moves the useful data nor copies it, due to
> performance.
>
>   * To use the *std::malloc* and *std::realloc* functions is a solution,
>     which requires to overload the *new* and *delete* operators to make
>     it oriented to objects.
>   * To create a *new* array, copy the useful objects and *delete* the
>     old array is a solution, which would be very slow if we shrink the
>     array a billion of times.
>   * The performance offered by the *std::vector* when shrinking could be
>     overcome by other implementations or native arrays
>     <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%201.cpp>.
>

I believe your calls to realloc(p, size-1) actually doesn't free up any
memory, which of course would be faster than shrinking the vector.


Bo Persson



--

---
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: contact@ncomputers.org
Date: Wed, 15 Oct 2014 11:48:04 -0700 (PDT)
Raw View
------=_Part_437_1180073683.1413398884105
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


>
> it's in fact clearly biased as your timing on vector tim both the=20
> allcoation of the vector and of its contents ... Why don't you just creat=
e=20
> vector on the stack instaed of by using new ??
>

Because the number of vectors or arrays used by the code by one of our=20
codes is undefined. It can vary with the time. The first second can be only=
=20
1, then 10, then 1,000, then 10, and so on.

Best regards,

http://ncomputers.org
=20
El mi=C3=A9rcoles, 15 de octubre de 2014 13:41:35 UTC-5, Joel Falcou escrib=
i=C3=B3:
>
> it's in fact clearly biased as your timing on vector tim both the=20
> allcoation of the vector and of its contents ... Why don't you just creat=
e=20
> vector on the stack instaed of by using new ??
>
> 2014-10-15 20:39 GMT+02:00 Joel Falcou <joel....@gmail.com <javascript:>>=
:
>
>> for such a benchmark to be valid it has to be done with a given=20
>> replicable protocol. If not it's meaning less. So do you have a=20
>> reproductible benchmark anybody can have a look at.=20
>> Abstarction penalty on std container is usually very low so I guess your=
=20
>> benchmark is biased.
>>
>> 2014-10-15 20:30 GMT+02:00 <con...@ncomputers.org <javascript:>>:
>>
>> Thank you very much for your time and your answer!
>>>
>>> The performance offered by the *std::vector* when shrinking could be=20
>>>> overcome by own implementations or native arrays=20
>>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays=
%201.cpp>
>>>> .
>>>
>>>
>>> It is probably due to: ISO/IEC JTC1/SC22/WG21 N3495=20
>>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm>
>>>
>>> Best regards,
>>>
>>> http://ncomputers.org=20
>>>
>>> El mi=C3=A9rcoles, 15 de octubre de 2014 13:15:16 UTC-5, Joel Falcou es=
cribi=C3=B3:
>>>>
>>>> why not using vector and resize or shrink_to_fit ?
>>>> handling raw memory using new/delete is usually ill advised in modern=
=20
>>>> c++
>>>>
>>>> 2014-10-15 19:47 GMT+02:00 <con...@ncomputers.org>:
>>>>
>>>>> Shrink dynamic arrays with delete[] operator
>>>>>
>>>>> It is very useful to shrink arrays, which were created using the *new=
*=20
>>>>> operator.
>>>>>
>>>>> *For example:*
>>>>>
>>>>> A code requires a billion of objects of a class to find a solution to=
=20
>>>>> a hard problem. As the code finds a new and better solution, some obj=
ects=20
>>>>> will become useless. Due to complexity, the code starts to require mo=
re=20
>>>>> time to process the useful data and find better solutions.
>>>>>
>>>>> As the code had a billion of useful objects in memory, it required=20
>>>>> only a few seconds to find a solution to the problem, because they we=
re=20
>>>>> easier to find. When the code searches better solutions, it requires =
less=20
>>>>> objects and more time. For example, when it searches a solution with =
only=20
>>>>> one million of objects, it will delay a week to find a new and better=
=20
>>>>> solution to the problem.
>>>>>
>>>>> It would be a waste of memory to have 999 millions of useless objects=
=20
>>>>> for a whole week. Just imagine, if every object requires ten bytes, t=
he=20
>>>>> code will be wasting 9.99 billions of bytes for a whole week.
>>>>>
>>>>> Thanks to the community of stackoverflow.com=20
>>>>> <http://www.stackoverflow.com>, cplusplus.com=20
>>>>> <http://www.cplusplus.com> and its contributors, we considered two=20
>>>>> possible solutions to shrink arrays:=20
>>>>>   =20
>>>>>    - Allocate memory using the *std::malloc* function and shrink the=
=20
>>>>>    array using the *std::realloc* function.
>>>>>    - Create a *new* array, copy the useful objects and *delete* the=
=20
>>>>>    old arrays.
>>>>>
>>>>> Both are good solutions.
>>>>>
>>>>> But we desire a solution, which is oriented to objects, automatically=
=20
>>>>> calls the destructors, is a C++ standard compatible with most memory=
=20
>>>>> allocators and neither moves the useful data nor copies it, due to=20
>>>>> performance.=20
>>>>>   =20
>>>>>    - To use the *std::malloc* and *std::realloc* functions is a=20
>>>>>    solution, which requires to overload the *new* and *delete*=20
>>>>>    operators to make it oriented to objects.
>>>>>    - To create a *new* array, copy the useful objects and *delete*=20
>>>>>    the old array is a solution, which would be very slow if we shrink=
 the=20
>>>>>    array a billion of times.
>>>>>    - The performance offered by the *std::vector* when shrinking coul=
d=20
>>>>>    be overcome by own implementations or native arrays=20
>>>>>    <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20ar=
rays%201.cpp>
>>>>>    .
>>>>>
>>>>> Our suggestion to make arrays shrinkable in a C++ oriented to objects=
=20
>>>>> way is the following:=20
>>>>>   =20
>>>>>    - Improve the *delete[]* operator syntax by this way:
>>>>>   =20
>>>>>    delete [objects to delete] pointer to array;
>>>>>   =20
>>>>>    where *delete[*0*]* is equivalent to delete nothing.
>>>>>
>>>>> We wrote the following partial solution to shrink arrays using an=20
>>>>> explicit call to an overloaded *delete[]* operator.
>>>>>
>>>>> *Examples: *Shrinkable arrays vs vectors |=20
>>>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20array=
s%201.cpp> Initialize=20
>>>>> undefined size arrays=20
>>>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20array=
s%202.cpp>
>>>>>
>>>>> /* author: ncomputers.org */
>>>>> #include<cstdlib>
>>>>> #include<iostream>
>>>>> using namespace std;
>>>>> =20
>>>>>  void*operator new[](size_t s){
>>>>>      return malloc(s);
>>>>>  }
>>>>>  void operator delete[](void*p){
>>>>>      free(p);
>>>>>  }
>>>>>  void operator delete[](void*p,size_t s){
>>>>>      //It doesn't support objects with destructor.
>>>>>      if(realloc(p,s)!=3Dp)throw 0;
>>>>>  }
>>>>> =20
>>>>>  int main(){
>>>>>      typedef int A;
>>>>>      A*a=3Dnew A[100];
>>>>>      //Suggested syntax:
>>>>>      //delete[90]a;
>>>>>      operator delete[](a,10*sizeof(A));
>>>>>      delete[]a;
>>>>>      return 0;
>>>>>  }=20
>>>>>
>>>>> Best regards,
>>>>>
>>>>> http://ncomputers.org=20
>>>>> <http://ncomputers.org/content/code.php?src=3Dsuggestions/shrink%20ar=
rays%20cpp>
>>>>> =20
>>>>> --=20
>>>>>
>>>>> ---=20
>>>>> You received this message because you are subscribed to the Google=20
>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, sen=
d=20
>>>>> an email to std-proposal...@isocpp.org.
>>>>> To post to this group, send email to std-pr...@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=20
>>> Groups "ISO C++ Standard - Future Proposals" group.
>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>> an email to std-proposal...@isocpp.org <javascript:>.
>>> To post to this group, send email to std-pr...@isocpp.org <javascript:>=
..
>>> Visit this group at=20
>>> 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/.

------=_Part_437_1180073683.1413398884105
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-lef=
t: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">=
it's in fact clearly biased as your timing on vector tim both the=20
allcoation of the vector and of its contents ... Why don't you just=20
create vector on the stack instaed of by using new ??<br></blockquote><div>=
<br>Because the number of vectors or arrays used by the code by one of our =
codes is undefined. It can vary with the time. The first second can be only=
 1, then 10, then 1,000, then 10, and so on.<br><br>Best regards,<br><br><a=
 href=3D"http://ncomputers.org">http://ncomputers.org</a><br>&nbsp;<br></di=
v>El mi=C3=A9rcoles, 15 de octubre de 2014 13:41:35 UTC-5, Joel Falcou escr=
ibi=C3=B3:<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">it'=
s in fact clearly biased as your timing on vector tim both the allcoation o=
f the vector and of its contents ... Why don't you just create vector on th=
e stack instaed of by using new ??<br></div><div><br><div class=3D"gmail_qu=
ote">2014-10-15 20:39 GMT+02:00 Joel Falcou <span dir=3D"ltr">&lt;<a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"C2nnvAdxjfQJ" o=
nmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=
=3D'javascript:';return true;">joel....@gmail.com</a>&gt;</span>:<br><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"ltr"><div>for such a benchmark to be v=
alid it has to be done with a given replicable protocol. If not it's meanin=
g less. So do you have a reproductible benchmark anybody can have a look at=
.. <br></div>Abstarction penalty on std container is usually very low so I g=
uess your benchmark is biased.<br></div><div><br><div class=3D"gmail_quote"=
>2014-10-15 20:30 GMT+02:00  <span dir=3D"ltr">&lt;<a href=3D"javascript:" =
target=3D"_blank" gdf-obfuscated-mailto=3D"C2nnvAdxjfQJ" onmousedown=3D"thi=
s.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';r=
eturn true;">con...@ncomputers.org</a>&gt;</span>:<div><div><br><blockquote=
 class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr">Thank you very much for your time and =
your answer!<span><br><br><blockquote style=3D"margin:0px 0px 0px 0.8ex;bor=
der-left:1px solid rgb(204,204,204);padding-left:1ex" class=3D"gmail_quote"=
>The performance offered by the <b>std::vector</b> when shrinking <a href=
=3D"http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%2=
01.cpp" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com=
/url?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%=
2Fshrink%2520arrays%25201.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf=
0rSm9Q5qJoJpYli0fA';return true;" onclick=3D"this.href=3D'http://www.google=
..com/url?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamp=
les%2Fshrink%2520arrays%25201.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFYB4p_=
Pisf0rSm9Q5qJoJpYli0fA';return true;">could be overcome by own implementati=
ons or native arrays</a>.</blockquote></span><div><br>It is probably due to=
: <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.=
htm" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/ur=
l?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F=
2013%2Fn3495.htm\46sa\75D\46sntz\0751\46usg\75AFQjCNHi805J7gBT6u6aQJjya5udz=
TuN7A';return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\75=
http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2013%2=
Fn3495.htm\46sa\75D\46sntz\0751\46usg\75AFQjCNHi805J7gBT6u6aQJjya5udzTuN7A'=
;return true;">ISO/IEC JTC1/SC22/WG21 N3495 </a><br><br>Best regards,<br><b=
r><a href=3D"http://ncomputers.org" target=3D"_blank" onmousedown=3D"this.h=
ref=3D'http://www.google.com/url?q\75http%3A%2F%2Fncomputers.org\46sa\75D\4=
6sntz\0751\46usg\75AFQjCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return true;" onclic=
k=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncomputers.org=
\46sa\75D\46sntz\0751\46usg\75AFQjCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return tr=
ue;">http://ncomputers.org</a>&nbsp;<br></div><br>El mi=C3=A9rcoles, 15 de =
octubre de 2014 13:15:16 UTC-5, Joel Falcou escribi=C3=B3:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><span><div dir=3D"ltr"><div>why not using vector and=
 resize or shrink_to_fit ?<br></div>handling raw memory using new/delete is=
 usually ill advised in modern c++<br></div></span><div><br><div class=3D"g=
mail_quote">2014-10-15 19:47 GMT+02:00  <span dir=3D"ltr">&lt;<a>con...@nco=
mputers.org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><di=
v dir=3D"ltr"><span><h1>Shrink dynamic arrays with delete[] operator<br></h=
1><br>It is very useful to shrink arrays, which were created using the <b>n=
ew</b> operator.<br><br>
<b>For example:</b><br><br></span><span>
A code requires a billion of objects of a class to find a solution to a har=
d problem.
As the code finds a new and better solution, some objects will become usele=
ss.
Due to complexity, the code starts to require more time to process the usef=
ul data and find better solutions.<br><br>
As the code had a billion of useful objects in memory, it required only a
 few seconds to find a solution to the problem, because they were easier
 to find.
When the code searches better solutions, it requires less objects and=20
more time. For example, when it searches a solution with only one=20
million of objects, it will delay a week to find a new and better=20
solution to the problem.<br><br>
It would be a waste of memory to have 999 millions of useless objects=20
for a whole week. Just imagine, if every object requires ten bytes, the=20
code will be wasting 9.99 billions of bytes for a whole week.<br><br>
Thanks to the community of <a href=3D"http://www.stackoverflow.com" target=
=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fwww.stackoverflow.com\46sa\75D\46sntz\0751\46usg\75AFQjCNHxis3Moxum=
f61TOKR4A6-hB0lXqQ';return true;" onclick=3D"this.href=3D'http://www.google=
..com/url?q\75http%3A%2F%2Fwww.stackoverflow.com\46sa\75D\46sntz\0751\46usg\=
75AFQjCNHxis3Moxumf61TOKR4A6-hB0lXqQ';return true;">stackoverflow.com</a>, =
<a href=3D"http://www.cplusplus.com" target=3D"_blank" onmousedown=3D"this.=
href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.cplusplus.com\46sa\7=
5D\46sntz\0751\46usg\75AFQjCNFaK0j9ns3fJtK0hIP8DIwVcCj74g';return true;" on=
click=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.cplusp=
lus.com\46sa\75D\46sntz\0751\46usg\75AFQjCNFaK0j9ns3fJtK0hIP8DIwVcCj74g';re=
turn true;">cplusplus.com</a> and its contributors, we considered two possi=
ble solutions to shrink arrays:
<ul><li>Allocate memory using the <b>std::malloc</b> function and shrink th=
e array using the <b>std::realloc</b> function.</li><li>Create a <b>new</b>=
 array, copy the useful objects and <b>delete</b> the old arrays.</li></ul>
Both are good solutions.<br><br>
But we desire a solution, which is oriented to objects, automatically=20
calls the destructors, is a C++ standard compatible with most memory=20
allocators and neither moves the useful data nor copies it, due to=20
performance.
<ul><li>To use the <b>std::malloc</b> and <b>std::realloc</b> functions is =
a solution, which requires to overload the <b>new</b> and <b>delete</b> ope=
rators to make it oriented to objects.</li><li>To create a <b>new</b> array=
, copy the useful objects and <b>delete</b> the old array is a solution, wh=
ich would be very slow if we shrink the array a billion of times.</li><li>T=
he performance offered by the <b>std::vector</b> when shrinking <a href=3D"=
http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201.c=
pp" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fsh=
rink%2520arrays%25201.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf0rSm=
9Q5qJoJpYli0fA';return true;" onclick=3D"this.href=3D'http://www.google.com=
/url?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%=
2Fshrink%2520arrays%25201.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf=
0rSm9Q5qJoJpYli0fA';return true;">could be overcome by own implementations =
or native arrays</a>.</li></ul>
Our suggestion to make arrays shrinkable in a C++ oriented to objects way i=
s the following:
<ul><li>Improve the <b>delete[]</b> operator syntax by this way:<br><br>
<span><span>delete</span> [objects to delete] pointer to array;</span><br><=
br>
where <b>delete[</b>0<b>]</b> is equivalent to delete nothing.</li></ul></s=
pan><span>
We wrote the following partial solution to shrink arrays using an explicit =
call to an overloaded <b>delete[]</b> operator.<br><br>
</span><div><div><b>Examples: </b><a href=3D"http://ncomputers.org/content/=
code.php?src=3Dexamples/shrink%20arrays%201.cpp" target=3D"_blank" onmoused=
own=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncomputers.o=
rg%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fshrink%2520arrays%25201.cpp\46sa=
\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf0rSm9Q5qJoJpYli0fA';return true;" =
onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncompute=
rs.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fshrink%2520arrays%25201.cpp\=
46sa\75D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf0rSm9Q5qJoJpYli0fA';return tru=
e;">Shrinkable arrays vs vectors |</a>
<a href=3D"http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20a=
rrays%202.cpp" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dex=
amples%2Fshrink%2520arrays%25202.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNHRE=
zi8AEWBBbtOfDy5XjccIwPkfw';return true;" onclick=3D"this.href=3D'http://www=
..google.com/url?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%=
3Dexamples%2Fshrink%2520arrays%25202.cpp\46sa\75D\46sntz\0751\46usg\75AFQjC=
NHREzi8AEWBBbtOfDy5XjccIwPkfw';return true;">Initialize undefined size arra=
ys</a><br><br><code><div style=3D"background-color:rgb(250,250,250);border-=
color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-=
word"><code><div><span style=3D"color:#800">/* author: <a href=3D"http://nc=
omputers.org" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.goog=
le.com/url?q\75http%3A%2F%2Fncomputers.org\46sa\75D\46sntz\0751\46usg\75AFQ=
jCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return true;" onclick=3D"this.href=3D'http=
://www.google.com/url?q\75http%3A%2F%2Fncomputers.org\46sa\75D\46sntz\0751\=
46usg\75AFQjCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return true;">ncomputers.org</a=
> */</span><span style=3D"color:#000"><br></span><span style=3D"color:#800"=
>#include</span><span style=3D"color:#080">&lt;cstdlib&gt;</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#800">#include</span><span=
 style=3D"color:#080">&lt;iostream&gt;</span><span style=3D"color:#000"><br=
></span><span style=3D"color:#008">using</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">namespace</span><span style=3D"color:#000=
"> std</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
<br>&nbsp;<br>&nbsp;</span><span style=3D"color:#008">void</span><span styl=
e=3D"color:#660">*</span><span style=3D"color:#008">operator</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">new</span><span style=
=3D"color:#660">[](</span><span style=3D"color:#000">size_t s</span><span s=
tyle=3D"color:#660">){</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &=
nbsp;</span><span style=3D"color:#008">return</span><span style=3D"color:#0=
00"> malloc</span><span style=3D"color:#660">(</span><span style=3D"color:#=
000">s</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
><br>&nbsp;</span><span style=3D"color:#660">}</span><span style=3D"color:#=
000"><br>&nbsp;</span><span style=3D"color:#008">void</span><span style=3D"=
color:#000"> </span><span style=3D"color:#008">operator</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">delete</span><span style=
=3D"color:#660">[](</span><span style=3D"color:#008">void</span><span style=
=3D"color:#660">*</span><span style=3D"color:#000">p</span><span style=3D"c=
olor:#660">){</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;free=
</span><span style=3D"color:#660">(</span><span style=3D"color:#000">p</spa=
n><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>&nbsp;=
</span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>&n=
bsp;</span><span style=3D"color:#008">void</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">operator</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">delete</span><span style=3D"color:#66=
0">[](</span><span style=3D"color:#008">void</span><span style=3D"color:#66=
0">*</span><span style=3D"color:#000">p</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000">size_t s</span><span style=3D"color:#660">=
){</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><span st=
yle=3D"color:#800">//It doesn't support objects with destructor.</span><spa=
n style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color:=
#008">if</span><span style=3D"color:#660">(</span><span style=3D"color:#000=
">realloc</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
0">p</span><span style=3D"color:#660">,</span><span style=3D"color:#000">s<=
/span><span style=3D"color:#660">)!=3D</span><span style=3D"color:#000">p</=
span><span style=3D"color:#660">)</span><span style=3D"color:#008">throw</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#066">0</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"><br>&nbsp;</sp=
an><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>&nbsp;=
<br>&nbsp;</span><span style=3D"color:#008">int</span><span style=3D"color:=
#000"> main</span><span style=3D"color:#660">(){</span><span style=3D"color=
:#000"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color:#008">typedef</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">int</span=
><span style=3D"color:#000"> A</span><span style=3D"color:#660">;</span><sp=
an style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;A</span><span style=3D"colo=
r:#660">*</span><span style=3D"color:#000">a</span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#008">new</span><span style=3D"color:#000=
"> A</span><span style=3D"color:#660">[</span><span style=3D"color:#066">10=
0</span><span style=3D"color:#660">];</span><span style=3D"color:#000"><br>=
&nbsp; &nbsp; &nbsp;</span><span style=3D"color:#800">//Suggested syntax:</=
span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><span style=
=3D"color:#800">//delete[90]a;</span><span style=3D"color:#000"><br>&nbsp; =
&nbsp; &nbsp;</span><span style=3D"color:#008">operator</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">delete</span><span style=
=3D"color:#660">[](</span><span style=3D"color:#000">a</span><span style=3D=
"color:#660">,</span><span style=3D"color:#066">10</span><span style=3D"col=
or:#660">*</span><span style=3D"color:#008">sizeof</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">A</span><span style=3D"color:#6=
60">));</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><sp=
an style=3D"color:#008">delete</span><span style=3D"color:#660">[]</span><s=
pan style=3D"color:#000">a</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"><br>&nbsp; &nbsp; &nbsp;</span><span style=3D"color:#00=
8">return</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">0</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><b=
r>&nbsp;</span><span style=3D"color:#660">}</span><span style=3D"color:#000=
"> <br></span></div></code></div><br>Best regards,<br><br><a href=3D"http:/=
/ncomputers.org/content/code.php?src=3Dsuggestions/shrink%20arrays%20cpp" t=
arget=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75=
http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dsuggestions%2Fshri=
nk%2520arrays%2520cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNHEBX0WCIGBqp1zLCaV=
5pohm9B36g';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dsuggestions%2=
Fshrink%2520arrays%2520cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNHEBX0WCIGBqp1=
zLCaV5pohm9B36g';return true;">http://ncomputers.org</a><br></code>
</div></div></div></div></div><div><div><div><div>

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br></div></div>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<span><br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<wbr>cpp.org/group/std-<u></u=
>proposals/</a>.<br>
</span></div></div></blockquote></div><br></div>
</blockquote></div><div><div>

<p></p>

-- <br>
<br>
--- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
C2nnvAdxjfQJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"C2nnvAdxjfQJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></div></blockquote></div></div></div><br></div>
</blockquote></div><br></div>
</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_437_1180073683.1413398884105--

.


Author: contact@ncomputers.org
Date: Wed, 15 Oct 2014 12:02:32 -0700 (PDT)
Raw View
------=_Part_550_30326505.1413399752536
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thank you very much for your time and your answer!

I invite you to watch memory usage running this code:

#include<cstdlib>
#include<stdio.h>
#include<iostream>
using namespace std;

void*operator new[](size_t s){
    return malloc(s);
}
void operator delete[](void*p){
    free(p);
}
void operator delete[](void*p,size_t s){
    if(realloc(p,s)!=3Dp)throw 0;
}

int main(){
    unsigned s=3D1024,S=3D1024*1024*1024;
    char*a=3Dnew char[S]();
    cout<<S<<" bytes allocated and initialized, press any key to shrink=20
array to "<<s<<" bytes"<<endl;
    getchar();
    operator delete[](a,s);
    cout<<"Array shrunk to "<<s<<" bytes, press any key to delete it"<<endl=
;
    getchar();
    delete[]a;
    return 0;
}

Best regards,

http://ncomputers.org

El mi=C3=A9rcoles, 15 de octubre de 2014 13:45:30 UTC-5, Bo Pesson escribi=
=C3=B3:
>
> On 2014-10-15 19:29, con...@ncomputers.org <javascript:> wrote:=20
> >=20
> >   Shrink dynamic arrays on C++=20
> >=20
> >=20
> > It is very useful to shrink arrays, which were created using the *new*=
=20
> > operator.=20
> >=20
> > *For example:*=20
> >=20
> > Your code requires a billion of objects of a class to find a solution t=
o=20
> > a hard problem. As the code finds a new and better solution, some=20
> > objects will become useless. Due to complexity, the code starts to=20
> > require more time to process the useful data and find better solutions.=
=20
> >=20
> > As the code had a billion of useful objects in memory, it required only=
=20
> > a few seconds to find a solution to the problem, because they were=20
> > easier to find. When the code searches better solutions, it requires=20
> > less objects and more time. For example, when it searches a solution=20
> > with only one million of objects, it will delay a week to find a new an=
d=20
> > better solution to the problem.=20
> >=20
> > It would be a waste of memory to have 999 millions of useless objects=
=20
> > for a whole week. Just imagine, if every object requires ten bytes, the=
=20
> > code will be wasting 9.99 billions of bytes for a whole week.=20
> >=20
> > Thanks to the community of stackoverflow.com=20
> > <http://www.stackoverflow.com>, cplusplus.com <http://www.cplusplus.com=
>=20
>
> > and its contributors, we considered two possible solutions to shrink=20
> > arrays:=20
> >=20
> >   * Allocate memory using the *std::malloc* function and shrink the=20
> >     array using the *std::realloc* function.=20
> >   * Create a *new* array, copy the useful objects and *delete* the old=
=20
> >     arrays.=20
> >=20
> > Both are good solutions.=20
> >=20
> > But we desire a solution, which is oriented to objects, automatically=
=20
> > calls the destructors, is a C++ standard compatible with most memory=20
> > allocators and neither moves the useful data nor copies it, due to=20
> > performance.=20
> >=20
> >   * To use the *std::malloc* and *std::realloc* functions is a solution=
,=20
> >     which requires to overload the *new* and *delete* operators to make=
=20
> >     it oriented to objects.=20
> >   * To create a *new* array, copy the useful objects and *delete* the=
=20
> >     old array is a solution, which would be very slow if we shrink the=
=20
> >     array a billion of times.=20
> >   * The performance offered by the *std::vector* when shrinking could b=
e=20
> >     overcome by other implementations or native arrays=20
> >     <
> http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%201=
..cpp>.=20
>
> >=20
>
> I believe your calls to realloc(p, size-1) actually doesn't free up any=
=20
> memory, which of course would be faster than shrinking the vector.=20
>
>
> Bo Persson=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_550_30326505.1413399752536
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thank you very much for your time and your answer!<br><br>=
I invite you to watch memory usage running this code:<br><br><div class=3D"=
prettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: r=
gb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break=
-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span sty=
le=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;cstdlib&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;stdio.h&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;iostream&gt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">namespace</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">void</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">*</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
operator</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">new</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">[](</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">size_t s</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">){</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> malloc</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">s</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-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></span><span style=3D"color: #008;" class=3D"styled-by-prettify">void<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">delete</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">[](</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">void</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">p</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">){</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp; &nbsp; free</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">p</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">delete</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">[](</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">void</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">p</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">size_t s</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">){</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">realloc</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">p</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
s</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)!=3D</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">p</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">throw</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> main</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">unsigned</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> s</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">1024</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">S</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">=3D</span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">1024</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*</span><span style=3D"color: #066;" class=3D"styled-by-prettify">1024<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">1024</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">new</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>char</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">S</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; 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">S</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">" bytes allocated and initia=
lized, press any key to shrink array to "</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">s</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&lt;&lt;</span><span style=3D"color: #080;" class=3D"st=
yled-by-prettify">" bytes"</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify">endl</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; &nbsp; getchar</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">operator</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">delete</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
[](</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">s</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>&nbsp; &nbsp; cout</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">"Array shrunk to "</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">s</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"c=
olor: #080;" class=3D"styled-by-prettify">" bytes, press any key to delete =
it"</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">endl</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; getcha=
r</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=
; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">[]</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">a</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; </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-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></span></div></code></div><br>Best regards,<br><br><a href=3D"http://n=
computers.org">http://ncomputers.org</a><br><br>El mi=C3=A9rcoles, 15 de oc=
tubre de 2014 13:45:30 UTC-5, Bo Pesson escribi=C3=B3:<blockquote class=3D"=
gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc so=
lid;padding-left: 1ex;">On 2014-10-15 19:29, <a href=3D"javascript:" target=
=3D"_blank" gdf-obfuscated-mailto=3D"GAinxYUhDhoJ" onmousedown=3D"this.href=
=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';return =
true;">con...@ncomputers.org</a> wrote:
<br>&gt;
<br>&gt; &nbsp; Shrink dynamic arrays on C++
<br>&gt;
<br>&gt;
<br>&gt; It is very useful to shrink arrays, which were created using the *=
new*
<br>&gt; operator.
<br>&gt;
<br>&gt; *For example:*
<br>&gt;
<br>&gt; Your code requires a billion of objects of a class to find a solut=
ion to
<br>&gt; a hard problem. As the code finds a new and better solution, some
<br>&gt; objects will become useless. Due to complexity, the code starts to
<br>&gt; require more time to process the useful data and find better solut=
ions.
<br>&gt;
<br>&gt; As the code had a billion of useful objects in memory, it required=
 only
<br>&gt; a few seconds to find a solution to the problem, because they were
<br>&gt; easier to find. When the code searches better solutions, it requir=
es
<br>&gt; less objects and more time. For example, when it searches a soluti=
on
<br>&gt; with only one million of objects, it will delay a week to find a n=
ew and
<br>&gt; better solution to the problem.
<br>&gt;
<br>&gt; It would be a waste of memory to have 999 millions of useless obje=
cts
<br>&gt; for a whole week. Just imagine, if every object requires ten bytes=
, the
<br>&gt; code will be wasting 9.99 billions of bytes for a whole week.
<br>&gt;
<br>&gt; Thanks to the community of <a href=3D"http://stackoverflow.com" ta=
rget=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75h=
ttp%3A%2F%2Fstackoverflow.com\46sa\75D\46sntz\0751\46usg\75AFQjCNFUoKKmZVS3=
Nibgy4xGsagbeUbT-Q';return true;" onclick=3D"this.href=3D'http://www.google=
..com/url?q\75http%3A%2F%2Fstackoverflow.com\46sa\75D\46sntz\0751\46usg\75AF=
QjCNFUoKKmZVS3Nibgy4xGsagbeUbT-Q';return true;">stackoverflow.com</a>
<br>&gt; &lt;<a href=3D"http://www.stackoverflow.com" target=3D"_blank" onm=
ousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.sta=
ckoverflow.com\46sa\75D\46sntz\0751\46usg\75AFQjCNHxis3Moxumf61TOKR4A6-hB0l=
XqQ';return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\75ht=
tp%3A%2F%2Fwww.stackoverflow.com\46sa\75D\46sntz\0751\46usg\75AFQjCNHxis3Mo=
xumf61TOKR4A6-hB0lXqQ';return true;">http://www.stackoverflow.com</a>&gt;<w=
br>, <a href=3D"http://cplusplus.com" target=3D"_blank" onmousedown=3D"this=
..href=3D'http://www.google.com/url?q\75http%3A%2F%2Fcplusplus.com\46sa\75D\=
46sntz\0751\46usg\75AFQjCNF4vo9LWgcpuWjyLarvfvueQ3viKw';return true;" oncli=
ck=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fcplusplus.com=
\46sa\75D\46sntz\0751\46usg\75AFQjCNF4vo9LWgcpuWjyLarvfvueQ3viKw';return tr=
ue;">cplusplus.com</a> &lt;<a href=3D"http://www.cplusplus.com" target=3D"_=
blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F=
%2Fwww.cplusplus.com\46sa\75D\46sntz\0751\46usg\75AFQjCNFaK0j9ns3fJtK0hIP8D=
IwVcCj74g';return true;" onclick=3D"this.href=3D'http://www.google.com/url?=
q\75http%3A%2F%2Fwww.cplusplus.com\46sa\75D\46sntz\0751\46usg\75AFQjCNFaK0j=
9ns3fJtK0hIP8DIwVcCj74g';return true;">http://www.cplusplus.com</a>&gt;
<br>&gt; and its contributors, we considered two possible solutions to shri=
nk
<br>&gt; arrays:
<br>&gt;
<br>&gt; &nbsp; * Allocate memory using the *std::malloc* function and shri=
nk the
<br>&gt; &nbsp; &nbsp; array using the *std::realloc* function.
<br>&gt; &nbsp; * Create a *new* array, copy the useful objects and *delete=
* the old
<br>&gt; &nbsp; &nbsp; arrays.
<br>&gt;
<br>&gt; Both are good solutions.
<br>&gt;
<br>&gt; But we desire a solution, which is oriented to objects, automatica=
lly
<br>&gt; calls the destructors, is a C++ standard compatible with most memo=
ry
<br>&gt; allocators and neither moves the useful data nor copies it, due to
<br>&gt; performance.
<br>&gt;
<br>&gt; &nbsp; * To use the *std::malloc* and *std::realloc* functions is =
a solution,
<br>&gt; &nbsp; &nbsp; which requires to overload the *new* and *delete* op=
erators to make
<br>&gt; &nbsp; &nbsp; it oriented to objects.
<br>&gt; &nbsp; * To create a *new* array, copy the useful objects and *del=
ete* the
<br>&gt; &nbsp; &nbsp; old array is a solution, which would be very slow if=
 we shrink the
<br>&gt; &nbsp; &nbsp; array a billion of times.
<br>&gt; &nbsp; * The performance offered by the *std::vector* when shrinki=
ng could be
<br>&gt; &nbsp; &nbsp; overcome by other implementations or native arrays
<br>&gt; &nbsp; &nbsp; &lt;<a href=3D"http://ncomputers.org/content/code.ph=
p?src=3Dexamples/shrink%20arrays%201.cpp" target=3D"_blank" onmousedown=3D"=
this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncomputers.org%2Fco=
ntent%2Fcode.php%3Fsrc%3Dexamples%2Fshrink%2520arrays%25201.cpp\46sa\75D\46=
sntz\0751\46usg\75AFQjCNFYB4p_Pisf0rSm9Q5qJoJpYli0fA';return true;" onclick=
=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncomputers.org%=
2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fshrink%2520arrays%25201.cpp\46sa\75=
D\46sntz\0751\46usg\75AFQjCNFYB4p_Pisf0rSm9Q5qJoJpYli0fA';return true;">htt=
p://ncomputers.org/<wbr>content/code.php?src=3Dexamples/<wbr>shrink%20array=
s%201.cpp</a>&gt;.
<br>&gt;
<br>
<br>I believe your calls to realloc(p, size-1) actually doesn't free up any=
=20
<br>memory, which of course would be faster than shrinking the vector.
<br>
<br>
<br>Bo Persson
<br>
<br>
<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_550_30326505.1413399752536--

.


Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Fri, 17 Oct 2014 22:38:46 +0330
Raw View
--089e01228d3e57b0f30505a31903
Content-Type: text/plain; charset=UTF-8

2014-10-15 22:11 GMT+03:30 Joel Falcou <joel.falcou@gmail.com>:

> it's in fact clearly biased as your timing on vector tim both the
> allcoation of the vector and of its contents ... Why don't you just create
> vector on the stack instaed of by using new ??
>

It is not biased, It is ill-formed.
The vector **has to** be placed on the stack because ***It is supposed to
replace the raw pointer in the other code***.
I smell C# from this code.

Regards,
FM.

--

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

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

<div dir=3D"rtl"><br><div class=3D"gmail_extra"><div dir=3D"ltr"><br><div c=
lass=3D"gmail_quote">2014-10-15 22:11 GMT+03:30 Joel Falcou <span dir=3D"lt=
r">&lt;<a href=3D"mailto:joel.falcou@gmail.com" target=3D"_blank">joel.falc=
ou@gmail.com</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">it&#39;s in =
fact clearly biased as your timing on vector tim both the allcoation of the=
 vector and of its contents ... Why don&#39;t you just create vector on the=
 stack instaed of by using new ??<br></blockquote><div><br></div><div>It is=
 not biased, It is ill-formed.</div><div>The vector **has to** be placed on=
 the stack because ***It is supposed to replace the raw pointer in the othe=
r code***.</div><div>I smell C# from this code.</div><div><br></div><div>Re=
gards,</div><div>FM.</div></div><div class=3D"HOEnZb"><div class=3D"h5"><di=
v class=3D"gmail_extra"><br></div></div></div></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 />

--089e01228d3e57b0f30505a31903--

.


Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Fri, 17 Oct 2014 22:54:23 +0330
Raw View
--089e01228d3e3338c80505a351dc
Content-Type: text/plain; charset=UTF-8

2014-10-15 22:18 GMT+03:30 <contact@ncomputers.org>:

> it's in fact clearly biased as your timing on vector tim both the
>> allcoation of the vector and of its contents ... Why don't you just create
>> vector on the stack instaed of by using new ??
>>
>
> Because the number of vectors or arrays used by the code by one of our
> codes is undefined. It can vary with the time. The first second can be only
> 1, then 10, then 1,000, then 10, and so on.
>
>
I`m afraid your short answer does not look vivid to me; Can u plz discus in
more details?

Regards,
FM.

--

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

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

<div dir=3D"rtl"><div class=3D"gmail_extra"><div dir=3D"ltr"><div class=3D"=
gmail_quote">2014-10-15 22:18 GMT+03:30  <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:contact@ncomputers.org" target=3D"_blank">contact@ncomputers.org</a>&=
gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><span class=3D""><blockquote =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa=
dding-left:1ex" class=3D"gmail_quote">it&#39;s in fact clearly biased as yo=
ur timing on vector tim both the=20
allcoation of the vector and of its contents ... Why don&#39;t you just=20
create vector on the stack instaed of by using new ??<br></blockquote></spa=
n><div><br>Because the number of vectors or arrays used by the code by one =
of our codes is undefined. It can vary with the time. The first second can =
be only 1, then 10, then 1,000, then 10, and so on.<br><br></div></blockquo=
te><div><br></div><div>I`m afraid your short answer does not look vivid to =
me; Can u plz discus in more details?</div><div><br></div><div>Regards,</di=
v><div>FM.</div></div></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 />

--089e01228d3e3338c80505a351dc--

.


Author: contact@ncomputers.org
Date: Fri, 17 Oct 2014 16:21:15 -0700 (PDT)
Raw View
------=_Part_811_686411781.1413588075078
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thank you very much for your time and your answer.

The code is inteded to compare both implementations when shrinking.

It is very strong related to this paper: n3495=20
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm>

I wrote these short codes to try to clarify it better, please consider that=
=20
english is a foreign language for me and sometimes it is easier to me to=20
express my point of view using codes, than words.

We create and delete the whole vector, beacuse these two reasons:

   1. The amount of vectors that the code will use is undefine during=20
   compile time.
   2. To call the constructor and the destructor of the objects is easier=
=20
   creating the whole vector and deleting it.
   3. Because we are comparing the performance when shrinking, we wrote the=
=20
   two test the most similiar we could, that means to use the new operator =
on=20
   both cases.
  =20
#include<iostream>
#include<vector>
using namespace std;

struct A{
    A(){
        cout<<"constructor"<<endl;
    }
    ~A(){
        cout<<"detructor"<<endl;
    }
};

int main(){
    delete new vector<A>(5);
}

As n3495 <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm=
>=20
says, *std::allocator* lose the advantages offered *realloc*.

This code is intended to show a disadvantage of the fact previously=20
mentioned. On some cases, rather when the performance is the main goal of a=
=20
code, it could be better to use *realloc* than to use=20
*std::vector::shrink_to_fit*, because it usualy moves the data, what is=20
intended to decrease memory fragmentation, but when it is better to have a=
=20
good performance than to avoid some fragmentation, *realloc* could be=20
chosen as the best option. Obviously when the blocks are moved, the=20
performance will decrease considerably.

#include<iostream>
#include<vector>
using namespace std;

int main(){
    try{
        unsigned S=3D1024;
        vector<int>a(S);
        for(unsigned s=3DS-1;s>0;--s){
            int*b=3D&a[0];
            cout<<b<<endl;
            a.resize(s);
            a.shrink_to_fit();
            int*c=3D&a[0];
            cout<<c<<endl;
            if(b!=3Dc){
                throw "Data moved!";
            }
        }
        cout<<"Data never moved"<<endl;
    }
    catch(char const*const& e){
        cout<<e<<endl;
    }
    return 0;
}

Please note that what we're purposing is to allow the shrinking of arrays=
=20
and even vectors without moving the data, what probably implies to add a=20
new functionallity to *std::allocator*, that allows it.

I've tested* realloc* with glibc and it never moved the data. It is very=20
useful to have the possibility to free some gigabytes when they became=20
useles despite fragmentation.

#include<cstdlib>
#include<iostream>
using namespace std;

int main(){
    try{
        unsigned S=3D1024;
        int*a=3D(int*)malloc(S*sizeof(int));
        for(unsigned s=3DS-1;s>0;--s){
            int*b=3D&a[0];
            cout<<b<<endl;
            a=3D(int*)realloc(a,s*sizeof(int));
            int*c=3D&a[0];
            cout<<c<<endl;
            if(b!=3Dc){
                throw "Data moved!";
            }
        }
        free(a);
        cout<<"Data never moved"<<endl;
    }
    catch(char const*const& e){
        cout<<e<<endl;
    }
    return 0;
}

El viernes, 17 de octubre de 2014 14:24:45 UTC-5, Farid Mehrabi escribi=C3=
=B3:
>
> 2014-10-15 22:18 GMT+03:30 <con...@ncomputers.org <javascript:>>:
>
>> it's in fact clearly biased as your timing on vector tim both the=20
>>> allcoation of the vector and of its contents ... Why don't you just cre=
ate=20
>>> vector on the stack instaed of by using new ??
>>>
>>
>> Because the number of vectors or arrays used by the code by one of our=
=20
>> codes is undefined. It can vary with the time. The first second can be o=
nly=20
>> 1, then 10, then 1,000, then 10, and so on.
>>
>>
> I`m afraid your short answer does not look vivid to me; Can u plz discus=
=20
> in more details?
>
> Regards,
> FM.
> =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_811_686411781.1413588075078
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thank you very much for your time and your answer.<br><br>=
The code is inteded to compare both implementations when shrinking.<br><br>=
It is very strong related to this paper: <a href=3D"http://www.open-std.org=
/jtc1/sc22/wg21/docs/papers/2013/n3495.htm">n3495</a><br><br>I wrote these =
short codes to try to clarify it better, please consider that english is a =
foreign language for me and sometimes it is easier to me to express my poin=
t of view using codes, than words.<br><br>We create and delete the whole ve=
ctor, beacuse these two reasons:<br><ol><li>The amount of vectors that the =
code will use is undefine during compile time.</li><li>To call the construc=
tor and the destructor of the objects is easier creating the whole vector a=
nd deleting it.</li><li>Because we are comparing the performance when shrin=
king, we wrote the two test the most similiar we could, that means to use t=
he new operator on both cases.<br></li></ol><div class=3D"prettyprint" styl=
e=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187)=
; border-style: solid; border-width: 1px; word-wrap: break-word;"><code cla=
ss=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #800=
;" class=3D"styled-by-prettify">#include</span><span style=3D"color: #080;"=
 class=3D"styled-by-prettify">&lt;iostream&gt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;"=
 class=3D"styled-by-prettify">#include</span><span style=3D"color: #080;" c=
lass=3D"styled-by-prettify">&lt;vector&gt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">namespace</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> A</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; A</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; =
&nbsp; cout</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;&lt;</span><span style=3D"color: #080;" class=3D"styled-by-prettify">"=
constructor"</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbs=
p; </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=
; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">~</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">A</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; c=
out</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span style=3D"color: #080;" class=3D"styled-by-prettify">"detructo=
r"</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">endl</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span sty=
le=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><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> main</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; </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">delete</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">new</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> vector</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">A</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span></div></code></div><br>As <a href=
=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm">n349=
5</a> says, <b>std::allocator</b> lose the advantages offered <b>realloc</b=
>.<br><br>This code is intended to show a disadvantage of the fact previous=
ly mentioned. On some cases, rather when the performance is the main goal o=
f a code, it could be better to use <b>realloc</b> than to use <b>std::vect=
or::shrink_to_fit</b>, because it usualy moves the data, what is intended t=
o decrease memory fragmentation, but when it is better to have a good perfo=
rmance than to avoid some fragmentation, <b>realloc</b> could be chosen as =
the best option. Obviously when the blocks are moved, the performance will =
decrease considerably.<br><br><div class=3D"prettyprint" style=3D"backgroun=
d-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style=
: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettypr=
int"><div class=3D"subprettyprint"><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">#include</span><span style=3D"color: #080;" class=3D"styl=
ed-by-prettify">&lt;iostream&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">#include</span><span style=3D"color: #080;" class=3D"styl=
ed-by-prettify">&lt;vector&gt;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">using</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
namespace</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"color: #000;" class=3D"styled-by-prettify"><br><br></span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">try</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">unsigned</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> S</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color:=
 #066;" class=3D"styled-by-prettify">1024</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; &nbsp; 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">a</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">S</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">for</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">unsigned</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> s</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">S</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 styl=
e=3D"color: #000;" class=3D"styled-by-prettify">s</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;--</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">s</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D&amp;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">];</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; cout</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">resize</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">s</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">shrink_to_fit</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">c</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">[</span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">0</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; &nbsp; &nbsp; &nbsp; cout</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">c</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">endl</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; &nbsp; &nbsp; &nbsp; </span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">if</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">!=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">c</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">throw</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">"Data moved!"</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nb=
sp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbs=
p; &nbsp; &nbsp; cout</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&lt;&lt;</span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">"Data never moved"</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>&nbsp; &nbsp; </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; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">catch</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> e</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; &nbsp; cout</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify">e</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">endl</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; </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; &nbsp; </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prett=
ify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v><br>Please note that what we're purposing is to allow the shrinking of ar=
rays and even vectors without moving the data, what probably implies to add=
 a new functionallity to <b>std::allocator</b>, that allows it.<br><br>I've=
 tested<b> realloc</b> with glibc and it never moved the data. It is very u=
seful to have the possibility to free some gigabytes when they became usele=
s despite fragmentation.<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: #800;" class=3D"=
styled-by-prettify">#include</span><span style=3D"color: #080;" class=3D"st=
yled-by-prettify">&lt;cstdlib&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">#include</span><span style=3D"color: #080;" class=3D"styl=
ed-by-prettify">&lt;iostream&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">using</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">namespace</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">try</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">unsigned</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> S</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #066;" class=3D"styled-by-prettify">1024</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D(</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">*)</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">malloc</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">S</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">));</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">for</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">unsigned</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> s</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">S</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 styl=
e=3D"color: #000;" class=3D"styled-by-prettify">s</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;--</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">s</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D&amp;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">];</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; cout</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D(</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">*)</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">realloc</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">s</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">));</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">c</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D&amp;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">a</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">];</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; cout</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">c</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">endl</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; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
!=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c</spa=
n><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=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">throw</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">"Data moved!"</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; &nbsp; &nbsp; &nbsp; &nbsp; </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; &nbsp; </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;=
 &nbsp; free</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp;=
 &nbsp; cout</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&lt;&lt;</span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
"Data never moved"</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">endl</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; </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; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ca=
tch</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">const</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> e</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">){</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>&nbsp; &nbsp; &nbsp; &nbsp; cout</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">e</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">endl</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; </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; </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">return</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</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></span></div></code></div><br>El =
viernes, 17 de octubre de 2014 14:24:45 UTC-5, Farid Mehrabi escribi=C3=B3:=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"rtl"><div><div dir=
=3D"ltr"><div class=3D"gmail_quote">2014-10-15 22:18 GMT+03:30  <span dir=
=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailt=
o=3D"TzrT0_--CBUJ" onmousedown=3D"this.href=3D'javascript:';return true;" o=
nclick=3D"this.href=3D'javascript:';return true;">con...@ncomputers.org</a>=
&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><span><blockquote style=3D"m=
argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left=
:1ex" class=3D"gmail_quote">it's in fact clearly biased as your timing on v=
ector tim both the=20
allcoation of the vector and of its contents ... Why don't you just=20
create vector on the stack instaed of by using new ??<br></blockquote></spa=
n><div><br>Because the number of vectors or arrays used by the code by one =
of our codes is undefined. It can vary with the time. The first second can =
be only 1, then 10, then 1,000, then 10, and so on.<br><br></div></blockquo=
te><div><br></div><div>I`m afraid your short answer does not look vivid to =
me; Can u plz discus in more details?</div><div><br></div><div>Regards,</di=
v><div>FM.</div></div></div>
</div></div>
</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_811_686411781.1413588075078--

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Fri, 17 Oct 2014 23:46:42 -0500
Raw View
--f46d0442888867a8290505ab2d60
Content-Type: text/plain; charset=UTF-8

On 17 October 2014 18:21, <contact@ncomputers.org> wrote:

>
>    1. The amount of vectors that the code will use is undefine during
>    compile time.
>
> So why not use a vector of vectors?


> As n3495
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm> says,
> *std::allocator* lose the advantages offered *realloc*.
>

realloc is a horrible interface that only works for things with trivial
copy constructors.  To add a general grow/shrink in place facility may
require replacing the entire malloc implementation to support it, which
would be a much bigger proposal than n3495.


> because it usualy moves the data,
>

No; it bitwise copies the data.


> I've tested* realloc* with glibc and it never moved the data.
>

Well, yeah, because you do exactly *one* heap allocation in your program
and then shrink the space; shrinking never has to move anything.  Not
exactly a realistic test for most programs...

If all you are doing is using POD types (such as int), why not just use
> realloc and be done with it?
> --
>
 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/.

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

<div dir=3D"ltr">On 17 October 2014 18:21,  <span dir=3D"ltr">&lt;<a href=
=3D"mailto:contact@ncomputers.org" target=3D"_blank">contact@ncomputers.org=
</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_qu=
ote"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:so=
lid;padding-left:1ex"><div dir=3D"ltr"><ol><li>The amount of vectors that t=
he code will use is undefine during compile time.</li></ol></div></blockquo=
te><div>So why not use a vector of vectors?</div><div>=C2=A0</div><blockquo=
te class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-widt=
h:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-le=
ft:1ex"><div dir=3D"ltr">As <a href=3D"http://www.open-std.org/jtc1/sc22/wg=
21/docs/papers/2013/n3495.htm" target=3D"_blank">n3495</a> says, <b>std::al=
locator</b> lose the advantages offered <b>realloc</b>.<br></div></blockquo=
te><div><br></div><div>realloc is a horrible interface that only works for =
things with trivial copy constructors.=C2=A0 To add a general grow/shrink i=
n place facility may require replacing the entire malloc implementation to =
support it, which would be a much bigger proposal than n3495.</div><div>=C2=
=A0=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div dir=3D"ltr">because it usualy moves th=
e data,</div></blockquote><div><br></div><div>No; it bitwise copies the dat=
a.</div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,2=
04);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">I&#39;ve tes=
ted<b> realloc</b> with glibc and it never moved the data. </div></blockquo=
te><div><br></div><div>Well, yeah, because you do exactly *one* heap alloca=
tion in your program and then shrink the space; shrinking never has to move=
 anything.=C2=A0 Not exactly a realistic test for most programs...</div><di=
v><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0=
..8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-s=
tyle:solid;padding-left:1ex"><div>If all you are doing is using POD types (=
such as int), why not just use realloc and be done with it?</div><div dir=
=3D"ltr">--=C2=A0<br></div></blockquote></div>=C2=A0Nevin &quot;:-)&quot; L=
iber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_=
blank">nevin@eviloverlord.com</a>&gt;=C2=A0 (847) 691-1404
</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 />

--f46d0442888867a8290505ab2d60--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 18 Oct 2014 13:15:00 +0800
Raw View
--Apple-Mail=_895ACE05-52DF-4428-8AF2-746F973AE371
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-10-18, at 12:46 PM, Nevin Liber <nevin@eviloverlord.com> wrote:

> realloc is a horrible interface that only works for things with trivial c=
opy constructors.  To add a general grow/shrink in place facility may requi=
re replacing the entire malloc implementation to support it, which would be=
 a much bigger proposal than n3495.

Really? I'd think the functionality could be sliced off any existing malloc=
.. Anyway, if it's not supported, just unconditionally return nullptr or wha=
tever. (Er, really no "whatever." To be practical, it has to be a null retu=
rn.)

There should be a generic interface for resizing allocations simply for the=
 sake of custom allocators. If it's something that many can do, then it sho=
uld be represented by the common interface.

N3495 has issues but I'm surprised by the lack of follow-up. Also, N3495 lo=
oks completely different from the one proposal I recall with a C++ adaptati=
on of realloc, which also had issues. So maybe I shouldn't really be surpri=
sed. Maybe I'll take a shot at it one day :P . But N3495 does hit most of t=
he right notes.

--=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=_895ACE05-52DF-4428-8AF2-746F973AE371
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;10&ndash;18, at 12:46 PM, Nevin Liber &lt;<a href=3D"mailto:nevin@evi=
loverlord.com">nevin@eviloverlord.com</a>&gt; wrote:</div><br class=3D"Appl=
e-interchange-newline"><blockquote type=3D"cite"><div style=3D"font-family:=
 Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font=
-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto=
; text-align: start; text-indent: 0px; text-transform: none; white-space: n=
ormal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">re=
alloc is a horrible interface that only works for things with trivial copy =
constructors.&nbsp; To add a general grow/shrink in place facility may requ=
ire replacing the entire malloc implementation to support it, which would b=
e a much bigger proposal than n3495.</div></blockquote><br></div><div>Reall=
y? I&rsquo;d think the functionality could be sliced off any existing mallo=
c. Anyway, if it&rsquo;s not supported, just unconditionally return nullptr=
 or whatever. (Er, really no &ldquo;whatever." To be practical, it has to b=
e a null return.)</div><div><br></div><div>There should be a generic interf=
ace for resizing allocations simply for the sake of custom allocators. If i=
t&rsquo;s something that many can do, then it should be represented by the =
common interface.</div><div><br></div><div>N3495 has issues but I&rsquo;m s=
urprised by the lack of follow-up. Also, N3495 looks completely different f=
rom the one proposal I recall with a C++ adaptation of realloc, which also =
had issues. So maybe I shouldn&rsquo;t really be surprised. Maybe I&rsquo;l=
l take a shot at it one day :P . But N3495 does hit most of the right notes=
..</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=_895ACE05-52DF-4428-8AF2-746F973AE371--

.


Author: contact@ncomputers.org
Date: Fri, 17 Oct 2014 22:19:32 -0700 (PDT)
Raw View
------=_Part_1484_249248235.1413609572094
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thank you very much for your time and your answer:

So why not use a vector of vectors?


One time someone made me the same question. So far my experiene says, when=
=20
the amount of vectors is undefined during compile time, it will be always=
=20
neccesary to use the new operator for each vector, despite it will be=20
contained by other vector. Can you prove the contrary?

To add a general grow/shrink in place facility may require replacing the=20
> entire malloc implementation to support it,


I agree with you, that's what be are indirectly purposing.

No; it bitwise copies the data.


So far my knowledge says, to move data means: To copy first the data and=20
then to delete, relase, free, etc. the old data, except when someone is=20
talking about the movement of the physical storage of the data.

Well, yeah, because you do exactly *one* heap allocation in your program=20
> and then shrink the space; shrinking never has to move anything.  Not=20
> exactly a realistic test for most programs...


We ran a long time test, with a lot of arrays, with random sizes, which=20
were shrunk to random sizes and the data was never moved. The goal of this=
=20
purpose is to improve the *std::allocator* and *delete[] *operator to allow=
=20
in place shrinking, which could offer great performance, not to standardize=
=20
the usage of *malloc*, *realloc* and *free.*

If all you are doing is using POD types (such as int), why not just use=20
> realloc and be done with it?


I invite you to see this code, which we posted above as example. We=20
understand your point and are also trying to make an overloaded *delete[]*=
=20
operator, which allows in-place shrinking, to support objcts with=20
destructors, all our tries and the tries of others couldn't achieve this,=
=20
because of the need of an explicit call to the *delete[]* operator, what=20
seen from our point of view, is another strong reason to improve the=20
*delete[]* operator.

void*operator new[](size_t s){
    return malloc(s);
}
void operator delete[](void*p){
    free(p);
}
void operator delete[](void*p,size_t s){
    //It doesn't support objects with destructor.
    if(realloc(p,s)!=3Dp)throw 0;
}

Best regards,

ncomputers.org

El viernes, 17 de octubre de 2014 23:47:25 UTC-5, Nevin ":-)" Liber=20
escribi=C3=B3:
>
> On 17 October 2014 18:21, <con...@ncomputers.org <javascript:>> wrote:
>
>>
>>    1. The amount of vectors that the code will use is undefine during=20
>>    compile time.
>>
>> So why not use a vector of vectors?
> =20
>
>> As n3495=20
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm>=20
>> says, *std::allocator* lose the advantages offered *realloc*.
>>
>
> realloc is a horrible interface that only works for things with trivial=
=20
> copy constructors.  To add a general grow/shrink in place facility may=20
> require replacing the entire malloc implementation to support it, which=
=20
> would be a much bigger proposal than n3495.
>  =20
>
>> because it usualy moves the data,
>>
>
> No; it bitwise copies the data.
> =20
>
>> I've tested* realloc* with glibc and it never moved the data.=20
>>
>
> Well, yeah, because you do exactly *one* heap allocation in your program=
=20
> and then shrink the space; shrinking never has to move anything.  Not=20
> exactly a realistic test for most programs...
>
> If all you are doing is using POD types (such as int), why not just use=
=20
>> realloc and be done with it?
>> --=20
>>
>  Nevin ":-)" Liber  <mailto:ne...@eviloverlord.com <javascript:>>  (847)=
=20
> 691-1404=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_1484_249248235.1413609572094
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thank you very much for your time and your answer:<br><br>=
<blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(=
204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">So why not use a =
vector of vectors?</blockquote><div><br>One time someone made me the same q=
uestion. So far my experiene says, when the amount of vectors is undefined =
during compile time, it will be always neccesary to use the new operator fo=
r each vector, despite it will be contained by other vector. Can you prove =
the contrary?<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border=
-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quo=
te">To add a general grow/shrink in place facility may require replacing th=
e entire malloc implementation to support it,</blockquote><div><br>I agree =
with you, that's what be are indirectly purposing.<br><br><blockquote style=
=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); p=
adding-left: 1ex;" class=3D"gmail_quote">No; it bitwise copies the data.</b=
lockquote><div><br>So far my knowledge says, to move data means: To copy fi=
rst the data and then to delete, relase, free, etc. the old data, except wh=
en someone is talking about the movement of the physical storage of the dat=
a.<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px =
solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">Well, y=
eah, because you do exactly *one* heap allocation in your program
 and then shrink the space; shrinking never has to move anything.&nbsp; Not=
=20
exactly a realistic test for most programs...</blockquote><div><br>We ran a=
 long time test, with a lot of arrays, with random sizes, which were shrunk=
 to random sizes and the data was never moved. The goal of this purpose is =
to improve the <b>std::allocator</b> and <b>delete[] </b>operator to allow =
in place shrinking, which could offer great performance, not to standardize=
 the usage of <b>malloc</b>, <b>realloc</b> and <b>free.</b><br><br><blockq=
uote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 20=
4, 204); padding-left: 1ex;" class=3D"gmail_quote">If all you are doing is =
using POD types (such as int), why not just use realloc and be done with it=
?</blockquote><br>I invite you to see this code, which we posted above as e=
xample. We understand your point and are also trying to make an overloaded =
<b>delete[]</b> operator, which allows in-place shrinking, to support objct=
s with destructors, all our tries and the tries of others couldn't achieve =
this, because of the need of an explicit call to the <b>delete[]</b> operat=
or, what seen from our point of view, is another strong reason to improve t=
he <b>delete[]</b> operator.<br><br><code><code><div class=3D"prettyprint" =
style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, =
187); border-style: solid; 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: #660;"=
 class=3D"styled-by-prettify">*</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">operator</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">new</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">[](</span><span style=3D"color: #000;" class=3D"styled-by-prettify">size=
_t s</span><span style=3D"color: #660;" class=3D"styled-by-prettify">){</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> malloc</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">s</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">);</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></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
operator</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[](</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">p</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; free</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">p</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">delete</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">[](</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">void</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">p</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t=
 s</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=
; </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//It doe=
sn't support objects with destructor.</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">if</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">realloc</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">p</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">s</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">)!=3D</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">p</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">throw</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"sty=
led-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</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></span></div=
></code></div><span style=3D"color:#000"><br></span></code></code>Best rega=
rds,<br><br><a href=3D"http://ncomputers.org">ncomputers.org</a><br></div><=
/div></div></div><br>El viernes, 17 de octubre de 2014 23:47:25 UTC-5, Nevi=
n ":-)" Liber escribi=C3=B3:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr">On 17 October 2014 18:21,  <span dir=3D"ltr">&lt;<a href=3D"=
javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"qGZXrFydyisJ" onmou=
sedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'j=
avascript:';return true;">con...@ncomputers.org</a>&gt;</span> wrote:<br><d=
iv><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,=
204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><ol><li>The=
 amount of vectors that the code will use is undefine during compile time.<=
/li></ol></div></blockquote><div>So why not use a vector of vectors?</div><=
div>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0=
px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-le=
ft-style:solid;padding-left:1ex"><div dir=3D"ltr">As <a href=3D"http://www.=
open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm" target=3D"_blank" o=
nmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.o=
pen-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2013%2Fn3495.htm\46sa\75=
D\46sntz\0751\46usg\75AFQjCNHi805J7gBT6u6aQJjya5udzTuN7A';return true;" onc=
lick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-st=
d.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2013%2Fn3495.htm\46sa\75D\46sn=
tz\0751\46usg\75AFQjCNHi805J7gBT6u6aQJjya5udzTuN7A';return true;">n3495</a>=
 says, <b>std::allocator</b> lose the advantages offered <b>realloc</b>.<br=
></div></blockquote><div><br></div><div>realloc is a horrible interface tha=
t only works for things with trivial copy constructors.&nbsp; To add a gene=
ral grow/shrink in place facility may require replacing the entire malloc i=
mplementation to support it, which would be a much bigger proposal than n34=
95.</div><div>&nbsp;&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,20=
4,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">because i=
t usualy moves the data,</div></blockquote><div><br></div><div>No; it bitwi=
se copies the data.</div><div>&nbsp;<br></div><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-co=
lor:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"=
ltr">I've tested<b> realloc</b> with glibc and it never moved the data. </d=
iv></blockquote><div><br></div><div>Well, yeah, because you do exactly *one=
* heap allocation in your program and then shrink the space; shrinking neve=
r has to move anything.&nbsp; Not exactly a realistic test for most program=
s...</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);=
border-left-style:solid;padding-left:1ex"><div>If all you are doing is usin=
g POD types (such as int), why not just use realloc and be done with it?</d=
iv><div dir=3D"ltr">--&nbsp;<br></div></blockquote></div>&nbsp;Nevin ":-)" =
Liber&nbsp; &lt;mailto:<a href=3D"javascript:" target=3D"_blank" gdf-obfusc=
ated-mailto=3D"qGZXrFydyisJ" onmousedown=3D"this.href=3D'javascript:';retur=
n true;" onclick=3D"this.href=3D'javascript:';return true;">ne...@eviloverl=
ord.com</a><wbr>&gt;&nbsp; (847) 691-1404
</div></div>
</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_1484_249248235.1413609572094--

.


Author: contact@ncomputers.org
Date: Fri, 17 Oct 2014 22:32:49 -0700 (PDT)
Raw View
------=_Part_888_864679812.1413610369045
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Quick correction:

To add a general grow/shrink in place facility may require replacing the=20
> entire malloc implementation to support it, which would be a much bigger=
=20
> proposal than n3495.


I agree with:

which would be a much bigger proposal than n3495.


We, think, that it is a bigger proposal than n3495.

It is n3495 + improvement to the delete[] operator.

I don't agree with this:

may require replacing the entire malloc implementation to support it


We want to use an *std::allocator* which supports inplace shrinking, not to=
=20
use *malloc*. The codes written by us, that you can find on this topic, use=
*=20
malloc*, *realloc* and *free* as example.

Best regards,

ncomputers.org

El viernes, 17 de octubre de 2014 23:47:25 UTC-5, Nevin ":-)" Liber=20
escribi=C3=B3:
>
> On 17 October 2014 18:21, <con...@ncomputers.org <javascript:>> wrote:
>
>>
>>    1. The amount of vectors that the code will use is undefine during=20
>>    compile time.
>>
>> So why not use a vector of vectors?
> =20
>
>> As n3495=20
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm>=20
>> says, *std::allocator* lose the advantages offered *realloc*.
>>
>
> realloc is a horrible interface that only works for things with trivial=
=20
> copy constructors.  To add a general grow/shrink in place facility may=20
> require replacing the entire malloc implementation to support it, which=
=20
> would be a much bigger proposal than n3495.
>  =20
>
>> because it usualy moves the data,
>>
>
> No; it bitwise copies the data.
> =20
>
>> I've tested* realloc* with glibc and it never moved the data.=20
>>
>
> Well, yeah, because you do exactly *one* heap allocation in your program=
=20
> and then shrink the space; shrinking never has to move anything.  Not=20
> exactly a realistic test for most programs...
>
> If all you are doing is using POD types (such as int), why not just use=
=20
>> realloc and be done with it?
>> --=20
>>
>  Nevin ":-)" Liber  <mailto:ne...@eviloverlord.com <javascript:>>  (847)=
=20
> 691-1404=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_888_864679812.1413610369045
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Quick correction:<br><br><blockquote style=3D"margin: 0px =
0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex=
;" class=3D"gmail_quote">To add a general grow/shrink in place facility may=
 require replacing the
 entire malloc implementation to support it, which would be a much=20
bigger proposal than n3495.</blockquote><div><br>I agree with:<br><br><bloc=
kquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, =
204, 204); padding-left: 1ex;" class=3D"gmail_quote">which would be a much=
=20
bigger proposal than n3495.</blockquote><div><br>We, think, that it is a bi=
gger proposal than n3495.<br><br>It is n3495 + improvement to the delete[] =
operator.<br><br>I don't agree with this:<br><br><blockquote style=3D"margi=
n: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-le=
ft: 1ex;" class=3D"gmail_quote">may require replacing the
 entire malloc implementation to support it</blockquote><div><br>We want to=
 use an <b>std::allocator</b> which supports inplace shrinking, not to use =
<b>malloc</b>. The codes written by us, that you can find on this topic, us=
e<b> malloc</b>, <b>realloc</b> and <b>free</b> as example.<br><br>Best reg=
ards,<br><br><a href=3D"http://ncomputers.org">ncomputers.org</a><br></div>=
</div></div><br>El viernes, 17 de octubre de 2014 23:47:25 UTC-5, Nevin ":-=
)" Liber escribi=C3=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr">On 17 October 2014 18:21,  <span dir=3D"ltr">&lt;<a href=3D"javas=
cript:" target=3D"_blank" gdf-obfuscated-mailto=3D"qGZXrFydyisJ" onmousedow=
n=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javasc=
ript:';return true;">con...@ncomputers.org</a>&gt;</span> wrote:<br><div><d=
iv class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);=
border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><ol><li>The amou=
nt of vectors that the code will use is undefine during compile time.</li><=
/ol></div></blockquote><div>So why not use a vector of vectors?</div><div>&=
nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-st=
yle:solid;padding-left:1ex"><div dir=3D"ltr">As <a href=3D"http://www.open-=
std.org/jtc1/sc22/wg21/docs/papers/2013/n3495.htm" target=3D"_blank" onmous=
edown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-s=
td.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2013%2Fn3495.htm\46sa\75D\46s=
ntz\0751\46usg\75AFQjCNHi805J7gBT6u6aQJjya5udzTuN7A';return true;" onclick=
=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.or=
g%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2013%2Fn3495.htm\46sa\75D\46sntz\0=
751\46usg\75AFQjCNHi805J7gBT6u6aQJjya5udzTuN7A';return true;">n3495</a> say=
s, <b>std::allocator</b> lose the advantages offered <b>realloc</b>.<br></d=
iv></blockquote><div><br></div><div>realloc is a horrible interface that on=
ly works for things with trivial copy constructors.&nbsp; To add a general =
grow/shrink in place facility may require replacing the entire malloc imple=
mentation to support it, which would be a much bigger proposal than n3495.<=
/div><div>&nbsp;&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,20=
4);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">because it us=
ualy moves the data,</div></blockquote><div><br></div><div>No; it bitwise c=
opies the data.</div><div>&nbsp;<br></div><blockquote class=3D"gmail_quote"=
 style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:=
rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"=
>I've tested<b> realloc</b> with glibc and it never moved the data. </div><=
/blockquote><div><br></div><div>Well, yeah, because you do exactly *one* he=
ap allocation in your program and then shrink the space; shrinking never ha=
s to move anything.&nbsp; Not exactly a realistic test for most programs...=
</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px =
0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bord=
er-left-style:solid;padding-left:1ex"><div>If all you are doing is using PO=
D types (such as int), why not just use realloc and be done with it?</div><=
div dir=3D"ltr">--&nbsp;<br></div></blockquote></div>&nbsp;Nevin ":-)" Libe=
r&nbsp; &lt;mailto:<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated=
-mailto=3D"qGZXrFydyisJ" onmousedown=3D"this.href=3D'javascript:';return tr=
ue;" onclick=3D"this.href=3D'javascript:';return true;">ne...@eviloverlord.=
com</a><wbr>&gt;&nbsp; (847) 691-1404
</div></div>
</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_888_864679812.1413610369045--

.


Author: contact@ncomputers.org
Date: Fri, 17 Oct 2014 22:38:56 -0700 (PDT)
Raw View
------=_Part_1750_1506508658.1413610736119
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thank you very much for your time and your answer!

I didn't understand exactly what you wrote:

I=E2=80=99d think the functionality could be sliced off any existing malloc=
..
>

I agree with this:

There should be a generic interface for resizing allocations simply for the=
=20
> sake of custom allocators. If it=E2=80=99s something that many can do, th=
en it=20
> should be represented by the common interface.
>

I didn't understand this:

N3495 looks completely different from the one proposal I recall with a C++=
=20
> adaptation of realloc, which also had issues.


Which porposal is "C++ adaptation of realloc"?

What did you want to express?

Maybe I=E2=80=99ll take a shot at it one day :P . But N3495 does hit most o=
f the=20
> right notes.


ncomputers.org

El s=C3=A1bado, 18 de octubre de 2014 00:15:18 UTC-5, David Krauss escribi=
=C3=B3:
>
>
> On 2014=E2=80=9310=E2=80=9318, at 12:46 PM, Nevin Liber <ne...@eviloverlo=
rd.com=20
> <javascript:>> wrote:
>
> realloc is a horrible interface that only works for things with trivial=
=20
> copy constructors.  To add a general grow/shrink in place facility may=20
> require replacing the entire malloc implementation to support it, which=
=20
> would be a much bigger proposal than n3495.
>
>
> Really? I=E2=80=99d think the functionality could be sliced off any exist=
ing=20
> malloc. Anyway, if it=E2=80=99s not supported, just unconditionally retur=
n nullptr=20
> or whatever. (Er, really no =E2=80=9Cwhatever." To be practical, it has t=
o be a=20
> null return.)
>
> There should be a generic interface for resizing allocations simply for=
=20
> the sake of custom allocators. If it=E2=80=99s something that many can do=
, then it=20
> should be represented by the common interface.
>
> N3495 has issues but I=E2=80=99m surprised by the lack of follow-up. Also=
, N3495=20
> looks completely different from the one proposal I recall with a C++=20
> adaptation of realloc, which also had issues. So maybe I shouldn=E2=80=99=
t really=20
> be surprised. Maybe I=E2=80=99ll take a shot at it one day :P . But N3495=
 does hit=20
> most of the right notes.
>

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

<div dir=3D"ltr">Thank you very much for your time and your answer!<br><br>=
I didn't understand exactly what you wrote:<br><br><blockquote style=3D"mar=
gin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-=
left: 1ex;" class=3D"gmail_quote"><div>I=E2=80=99d think the functionality =
could be sliced off any=20
existing malloc.<br></div></blockquote><div><br>I agree with this:<br><br><=
/div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid=
 rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote"><div>There s=
hould be a=20
generic interface for resizing allocations simply for the sake of custom
 allocators. If it=E2=80=99s something that many can do, then it should be=
=20
represented by the common interface.</div></blockquote><div><br>I didn't un=
derstand this:<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; borde=
r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_qu=
ote">N3495 looks=20
completely different from the one proposal I recall with a C++=20
adaptation of realloc, which also had issues.</blockquote><div><br>Which po=
rposal is "C++ adaptation of realloc"?<br><br>What did you want to express?=
<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px so=
lid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">Maybe I=
=E2=80=99ll take a shot at it one day :P . But N3495
 does hit most of the right notes.</blockquote><div><br></div></div></div><=
a href=3D"http://ncomputers.org">ncomputers.org</a><br><br>El s=C3=A1bado, =
18 de octubre de 2014 00:15:18 UTC-5, David Krauss escribi=C3=B3:<blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:break-word"><br>=
<div><div>On 2014=E2=80=9310=E2=80=9318, at 12:46 PM, Nevin Liber &lt;<a hr=
ef=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"zfAtBy3v-okJ"=
 onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.hre=
f=3D'javascript:';return true;">ne...@eviloverlord.com</a>&gt; wrote:</div>=
<br><blockquote type=3D"cite"><div style=3D"font-family:Helvetica;font-size=
:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spaci=
ng:normal;line-height:normal;text-align:start;text-indent:0px;text-transfor=
m:none;white-space:normal;word-spacing:0px">realloc is a horrible interface=
 that only works for things with trivial copy constructors.&nbsp; To add a =
general grow/shrink in place facility may require replacing the entire mall=
oc implementation to support it, which would be a much bigger proposal than=
 n3495.</div></blockquote><br></div><div>Really? I=E2=80=99d think the func=
tionality could be sliced off any existing malloc. Anyway, if it=E2=80=99s =
not supported, just unconditionally return nullptr or whatever. (Er, really=
 no =E2=80=9Cwhatever." To be practical, it has to be a null return.)</div>=
<div><br></div><div>There should be a generic interface for resizing alloca=
tions simply for the sake of custom allocators. If it=E2=80=99s something t=
hat many can do, then it should be represented by the common interface.</di=
v><div><br></div><div>N3495 has issues but I=E2=80=99m surprised by the lac=
k of follow-up. Also, N3495 looks completely different from the one proposa=
l I recall with a C++ adaptation of realloc, which also had issues. So mayb=
e I shouldn=E2=80=99t really be surprised. Maybe I=E2=80=99ll take a shot a=
t it one day :P . But N3495 does hit most of the right notes.</div></div></=
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_1750_1506508658.1413610736119--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 18 Oct 2014 13:43:02 +0800
Raw View
--Apple-Mail=_B2901C98-3B20-448C-848E-9DE35AFCE28A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-10-18, at 1:38 PM, contact@ncomputers.org wrote:

> Thank you very much for your time and your answer!
>=20
> I didn't understand exactly what you wrote:
>=20
> I'd think the functionality could be sliced off any existing malloc.

Nevin said that resizing malloc allocations would require a rewrite of mall=
oc. I think that it would not be a total rewrite, but only an adaptation of=
 code that should already exist for realloc. And anyway, it shouldn't be a =
big deal when a platform doesn't support it.

> I didn't understand this:
>=20
> N3495 looks completely different from the one proposal I recall with a C+=
+ adaptation of realloc, which also had issues.
>=20
> Which porposal is "C++ adaptation of realloc"?
>=20
> What did you want to express?

Anything that provides a capability to change the size of an allocation wit=
hout getting into realloc's requirement of trivial copyability, I'd conside=
r to be a C++ adaptation of realloc. There have been several, but I'm not d=
igging for the others right now.

--=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=_B2901C98-3B20-448C-848E-9DE35AFCE28A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;10&ndash;18, at 1:38 PM, <a href=3D"mailto:contact@ncomputers.org">co=
ntact@ncomputers.org</a> wrote:</div><br class=3D"Apple-interchange-newline=
"><blockquote type=3D"cite"><div style=3D"font-family: Helvetica; font-size=
: 12px; font-style: normal; font-variant: normal; font-weight: normal; lett=
er-spacing: normal; line-height: normal; orphans: auto; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir=3D"ltr">Thank =
you very much for your time and your answer!<br><br>I didn't understand exa=
ctly what you wrote:<br><br><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; bo=
rder-left-color: rgb(204, 204, 204); padding-left: 1ex;">I&rsquo;d think th=
e functionality could be sliced off any existing malloc.<br></blockquote></=
div></div></blockquote><div><br></div><div>Nevin said that resizing malloc =
allocations would require a rewrite of malloc. I think that it would not be=
 a total rewrite, but only an adaptation of code that should already exist =
for realloc. And anyway, it shouldn&rsquo;t be a big deal when a platform d=
oesn&rsquo;t support it.</div><br><blockquote type=3D"cite"><div style=3D"f=
ont-family: Helvetica; font-size: 12px; font-style: normal; font-variant: n=
ormal; font-weight: normal; letter-spacing: normal; line-height: normal; or=
phans: auto; text-align: start; text-indent: 0px; text-transform: none; whi=
te-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-widt=
h: 0px;"><div dir=3D"ltr"><div>I didn't understand this:</div><div><br><blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-le=
ft-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 2=
04); padding-left: 1ex; position: static; z-index: auto;">N3495 looks compl=
etely different from the one proposal I recall with a C++ adaptation of rea=
lloc, which also had issues.</blockquote><div><br>Which porposal is "C++ ad=
aptation of realloc"?<br><br>What did you want to express?<br></div></div><=
/div></div></blockquote><div><br></div><div>Anything that provides a capabi=
lity to change the size of an allocation without getting into realloc&rsquo=
;s requirement of trivial copyability, I&rsquo;d consider to be a C++ adapt=
ation of realloc. There have been several, but I&rsquo;m not digging for th=
e others right now.</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=_B2901C98-3B20-448C-848E-9DE35AFCE28A--

.


Author: contact@ncomputers.org
Date: Fri, 17 Oct 2014 23:02:16 -0700 (PDT)
Raw View
------=_Part_1684_390694103.1413612136958
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

David, thank you very much for your answer!

it shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t support =
it.


I agree with it.

 There have been several, but I=E2=80=99m not digging for the others right =
now.


I understand it. So far my experience says, it is easier to propose=20
something new, than that the proposals become accepted. We're excepting=20
that it could even require more than ten years,=20
that the *std::allocator* become standardized to allow in-place resizing.

One of our objectives is to share this idea for the improvement of the=20
*delete[]* operator, so programmers around the world can know it and the=20
right ones, will achieve to standardize such proposals or similars.

The codes that we're writting could free some megabytes of useless data and=
=20
we're writting in them (commented):

//Awaiting shrinkable arrays:
delete [oldSize - newSize] pointer;

So, when shrinkable arrays are possible, someone will uncomment the lines=
=20
and those megabytes of waste can be freed.

Unfortunately we don't have neither the necessary experience nor the time=
=20
to write a paper, which has high possibilities to be accepted and=20
standardized, but how do you think, that we can contribute to support every=
=20
reasonable proposal of what you call:

C++ adaptation of realloc
>

And to make programmers consider the possibility of having a logical *new[*
size*]* and *delete[*size*]* operators?

ncomputers.org

El s=C3=A1bado, 18 de octubre de 2014 00:43:16 UTC-5, David Krauss escribi=
=C3=B3:
>
>
> On 2014=E2=80=9310=E2=80=9318, at 1:38 PM, con...@ncomputers.org <javascr=
ipt:> wrote:
>
> Thank you very much for your time and your answer!
>
> I didn't understand exactly what you wrote:
>
> I=E2=80=99d think the functionality could be sliced off any existing mall=
oc.
>>
>
> Nevin said that resizing malloc allocations would require a rewrite of=20
> malloc. I think that it would not be a total rewrite, but only an=20
> adaptation of code that should already exist for realloc. And anyway, it=
=20
> shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t support i=
t.
>
> I didn't understand this:
>
> N3495 looks completely different from the one proposal I recall with a C+=
+=20
>> adaptation of realloc, which also had issues.
>
>
> Which porposal is "C++ adaptation of realloc"?
>
> What did you want to express?
>
>
> Anything that provides a capability to change the size of an allocation=
=20
> without getting into realloc=E2=80=99s requirement of trivial copyability=
, I=E2=80=99d=20
> consider to be a C++ adaptation of realloc. There have been several, but=
=20
> I=E2=80=99m not digging for the others right now.
>

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

<div dir=3D"ltr">David, thank you very much for your answer!<br><br><blockq=
uote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 20=
4, 204); padding-left: 1ex;" class=3D"gmail_quote">it shouldn=E2=80=99t be =
a big deal when a platform doesn=E2=80=99t support it.</blockquote><div><br=
>I agree with it.<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; bo=
rder-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail=
_quote">&nbsp;There have been several, but I=E2=80=99m not digging for the =
others right now.</blockquote><div><br>I understand it. So far my experienc=
e says, it is easier to propose something new, than that the proposals beco=
me accepted. We're excepting that it could even require more than ten years=
, <br>that the <b>std::allocator</b> become standardized to allow in-place =
resizing.<br><br>One of our objectives is to share this idea for the improv=
ement of the <b>delete[]</b> operator, so programmers around the world can =
know it and the right ones, will achieve to standardize such proposals or s=
imilars.<br><br>The codes that we're writting could free some megabytes of =
useless data and we're writting in them (commented):<br><br><div class=3D"p=
rettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rg=
b(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-=
word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #800;" class=3D"styled-by-prettify">//Awaiting shrinkable array=
s:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">oldSize </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> newSize</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> pointer</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></span></div></code></div><br>So, when shrinkable arrays are poss=
ible, someone will uncomment the lines and those megabytes of waste can be =
freed.<br><br>Unfortunately we don't have neither the necessary experience =
nor the time to write a paper, which has high possibilities to be accepted =
and standardized, but how do you think, that we can contribute to support e=
very reasonable proposal of what you call:<br><br><blockquote style=3D"marg=
in: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-l=
eft: 1ex;" class=3D"gmail_quote">C++ adaptation of realloc<br></blockquote>=
<div><br>And to make programmers consider the possibility of having a logic=
al <b>new[</b>size<b>]</b> and <b>delete[</b>size<b>]</b> operators?<br><br=
><a href=3D"http://ncomputers.org">ncomputers.org</a><br></div></div></div>=
<br>El s=C3=A1bado, 18 de octubre de 2014 00:43:16 UTC-5, David Krauss escr=
ibi=C3=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-w=
rap:break-word"><br><div><div>On 2014=E2=80=9310=E2=80=9318, at 1:38 PM, <a=
 href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"eH3hweq65n=
8J" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.=
href=3D'javascript:';return true;">con...@ncomputers.org</a> wrote:</div><b=
r><blockquote type=3D"cite"><div style=3D"font-family:Helvetica;font-size:1=
2px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing=
:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:=
none;white-space:normal;word-spacing:0px"><div dir=3D"ltr">Thank you very m=
uch for your time and your answer!<br><br>I didn't understand exactly what =
you wrote:<br><br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:=
rgb(204,204,204);padding-left:1ex">I=E2=80=99d think the functionality coul=
d be sliced off any existing malloc.<br></blockquote></div></div></blockquo=
te><div><br></div><div>Nevin said that resizing malloc allocations would re=
quire a rewrite of malloc. I think that it would not be a total rewrite, bu=
t only an adaptation of code that should already exist for realloc. And any=
way, it shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t sup=
port it.</div><br><blockquote type=3D"cite"><div style=3D"font-family:Helve=
tica;font-size:12px;font-style:normal;font-variant:normal;font-weight:norma=
l;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px=
;text-transform:none;white-space:normal;word-spacing:0px"><div dir=3D"ltr">=
<div>I didn't understand this:</div><div><br><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-sty=
le:solid;border-left-color:rgb(204,204,204);padding-left:1ex">N3495 looks c=
ompletely different from the one proposal I recall with a C++ adaptation of=
 realloc, which also had issues.</blockquote><div><br>Which porposal is "C+=
+ adaptation of realloc"?<br><br>What did you want to express?<br></div></d=
iv></div></div></blockquote><div><br></div><div>Anything that provides a ca=
pability to change the size of an allocation without getting into realloc=
=E2=80=99s requirement of trivial copyability, I=E2=80=99d consider to be a=
 C++ adaptation of realloc. There have been several, but I=E2=80=99m not di=
gging for the others right now.</div></div></div></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_1684_390694103.1413612136958--

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Sat, 18 Oct 2014 01:23:20 -0500
Raw View
--001a1139adbaff74460505ac8656
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 18 October 2014 00:43, David Krauss <potswa@gmail.com> wrote:

>
> Nevin said that resizing malloc allocations would require a rewrite of
> malloc. I think that it would not be a total rewrite, but only an
> adaptation of code that should already exist for realloc. And anyway, it
> shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t support i=
t.
>

But malloc is typically in the domain of C and the OS.  On some systems for
instance, you can intercept the malloc calls and replace them.  It is not
trivial to add a reallocate-in-place facility that remains compatible with
all these real world malloc implementations.

To properly take advantage of this, you need to change vector, allocators
and malloc.  Now, given that most programs interleave allocations made in
different objects (think about a vector<string>, for instance), you then
have to benchmark your implementation to show under what circumstances it
is a clear win for adding all this complexity.

That's a lot of work.  Assuming the outcome is a performance win for adding
reallocate-in-place, then you have a shot at a proposal being successful.
--=20
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

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

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

<div dir=3D"ltr">On 18 October 2014 00:43, David Krauss <span dir=3D"ltr">&=
lt;<a href=3D"mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</=
a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quot=
e"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><br><=
div><span class=3D""><div>Nevin said that resizing malloc allocations would=
 require a rewrite of malloc. I think that it would not be a total rewrite,=
 but only an adaptation of code that should already exist for realloc. And =
anyway, it shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t =
support it.</div></span></div></div></blockquote><div><br></div><div>But ma=
lloc is typically in the domain of C and the OS.=C2=A0 On some systems for =
instance, you can intercept the malloc calls and replace them.=C2=A0 It is =
not trivial to add a reallocate-in-place facility that remains compatible w=
ith all these real world malloc implementations.</div><div><br></div><div>T=
o properly take advantage of this, you need to change vector, allocators an=
d malloc.=C2=A0 Now, given that most programs interleave allocations made i=
n different objects (think about a vector&lt;string&gt;, for instance), you=
 then have to benchmark your implementation to show under what circumstance=
s it is a clear win for adding all this complexity.</div><div><br></div><di=
v>That&#39;s a lot of work.=C2=A0 Assuming the outcome is a performance win=
 for adding reallocate-in-place, then you have a shot at a proposal being s=
uccessful.</div></div>-- <br>=C2=A0Nevin &quot;:-)&quot; Liber=C2=A0 &lt;ma=
ilto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@evil=
overlord.com</a>&gt;=C2=A0 (847) 691-1404
</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 />

--001a1139adbaff74460505ac8656--

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Sat, 18 Oct 2014 01:36:33 -0500
Raw View
--047d7bb03afa40cbe40505acb6a5
Content-Type: text/plain; charset=UTF-8

On 18 October 2014 01:02, <contact@ncomputers.org> wrote:

> I understand it. So far my experience says, it is easier to propose
> something new, than that the proposals become accepted. We're excepting
> that it could even require more than ten years,
> that the *std::allocator* become standardized to allow in-place resizing.
>

std::allocator must call  ::operator new(std::size_t) to get space, so it
has to be compatible with that.  Plus, it is extremely unlikely that making
std::allocator having a different interface than other allocators would
ever pass.


> Unfortunately we don't have neither the necessary experience nor the time
> to write a paper,
>
--
 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/.

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

<div dir=3D"ltr">On 18 October 2014 01:02,  <span dir=3D"ltr">&lt;<a href=
=3D"mailto:contact@ncomputers.org" target=3D"_blank">contact@ncomputers.org=
</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_qu=
ote"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:so=
lid;padding-left:1ex"><div dir=3D"ltr"><div><div>I understand it. So far my=
 experience says, it is easier to propose something new, than that the prop=
osals become accepted. We&#39;re excepting that it could even require more =
than ten years, <br>that the <b>std::allocator</b> become standardized to a=
llow in-place resizing.<br></div></div></div></blockquote><div><br></div><d=
iv>std::allocator must call=C2=A0<span style=3D"font-family:Helvetica;font-=
size:10px">=C2=A0</span><span style=3D"font-family:Helvetica;font-size:10px=
">::operator new(std::size_t)</span>=C2=A0to get space, so it has to be com=
patible with that.=C2=A0 Plus, it is extremely unlikely that making std::al=
locator having a different interface than other allocators would ever pass.=
<br></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204=
);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><div><div>Unfo=
rtunately we don&#39;t have neither the necessary experience nor the time t=
o write a paper,</div></div></div></blockquote><div>--=C2=A0<br></div></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 (=
847) 691-1404
</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 />

--047d7bb03afa40cbe40505acb6a5--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 18 Oct 2014 14:41:46 +0800
Raw View
--Apple-Mail=_F25834A9-2799-4FD8-9637-BB5A89AB55D5
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-10-18, at 2:23 PM, Nevin Liber <nevin@eviloverlord.com> wrote:

> But malloc is typically in the domain of C and the OS.  On some systems f=
or instance, you can intercept the malloc calls and replace them.  It is no=
t trivial to add a reallocate-in-place facility that remains compatible wit=
h all these real world malloc implementations.

That's why my suggestion is to focus on the generic Allocator concept, not =
on std::allocator.

> To properly take advantage of this, you need to change vector, allocators=
 and malloc.  Now, given that most programs interleave allocations made in =
different objects (think about a vector<string>, for instance), you then ha=
ve to benchmark your implementation to show under what circumstances it is =
a clear win for adding all this complexity.

You can get phenomenal performance by tuning a program to use a few string =
arenas without interleaving. The bytes recovered by an eager shrink-to-fit =
operation on the last allocation are going to be in L1 cache, and they're t=
he next to get allocated.

How much improvement to everyday programs, when shrink-to-fit is enabled wi=
th malloc? Maybe not much. But that's only one side of the argument. It's s=
till worthwhile to enable better performance in fast allocators with proper=
 support. Right now, the allocator gets coupled unnecessarily to the algori=
thm because this one generic interface is missing.

--=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=_F25834A9-2799-4FD8-9637-BB5A89AB55D5
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;10&ndash;18, at 2:23 PM, Nevin Liber &lt;<a href=3D"mailto:nevin@evil=
overlord.com">nevin@eviloverlord.com</a>&gt; wrote:</div><br class=3D"Apple=
-interchange-newline"><blockquote type=3D"cite"><div class=3D"gmail_quote" =
style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; font-=
variant: normal; font-weight: normal; letter-spacing: normal; line-height: =
normal; orphans: auto; text-align: start; text-indent: 0px; text-transform:=
 none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-s=
troke-width: 0px;"><div>But malloc is typically in the domain of C and the =
OS.&nbsp; On some systems for instance, you can intercept the malloc calls =
and replace them.&nbsp; It is not trivial to add a reallocate-in-place faci=
lity that remains compatible with all these real world malloc implementatio=
ns.</div></div></blockquote><div><br></div><div>That&rsquo;s why my suggest=
ion is to focus on the generic Allocator concept, not on <font face=3D"Cour=
ier">std::allocator</font>.</div><br><blockquote type=3D"cite"><div class=
=3D"gmail_quote" style=3D"font-family: Helvetica; font-size: 12px; font-sty=
le: normal; font-variant: normal; font-weight: normal; letter-spacing: norm=
al; line-height: normal; orphans: auto; text-align: start; text-indent: 0px=
; text-transform: none; white-space: normal; widows: auto; word-spacing: 0p=
x; -webkit-text-stroke-width: 0px;"><div>To properly take advantage of this=
, you need to change vector, allocators and malloc.&nbsp; Now, given that m=
ost programs interleave allocations made in different objects (think about =
a vector&lt;string&gt;, for instance), you then have to benchmark your impl=
ementation to show under what circumstances it is a clear win for adding al=
l this complexity.</div></div></blockquote><div><br></div><div>You can get =
phenomenal performance by tuning a program to use a few string arenas witho=
ut interleaving. The bytes recovered by an eager shrink-to-fit operation on=
 the last allocation are going to be in L1 cache, and they&rsquo;re the nex=
t to get allocated.</div><div><br></div><div>How much improvement to everyd=
ay programs, when shrink-to-fit is enabled with malloc? Maybe not much. But=
 that&rsquo;s only one side of the argument. It&rsquo;s still worthwhile to=
 enable better performance in fast allocators with proper support. Right no=
w, the allocator gets coupled unnecessarily to the algorithm because this o=
ne generic interface is missing.</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=_F25834A9-2799-4FD8-9637-BB5A89AB55D5--

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Sat, 18 Oct 2014 01:57:07 -0500
Raw View
--047d7bfced1cd04b370505acff91
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 18 October 2014 01:41, David Krauss <potswa@gmail.com> wrote:

>
> You can get phenomenal performance by tuning a program to use a few strin=
g
> arenas without interleaving. The bytes recovered by an eager shrink-to-fi=
t
> operation on the last allocation are going to be in L1 cache, and they=E2=
=80=99re
> the next to get allocated.
>

Oh, sure.


>
> How much improvement to everyday programs, when shrink-to-fit is enabled
> with malloc? Maybe not much. But that=E2=80=99s only one side of the argu=
ment. It=E2=80=99s
> still worthwhile to enable better performance in fast allocators with
> proper support. Right now, the allocator gets coupled unnecessarily to th=
e
> algorithm because this one generic interface is missing.
>

You cannot say it is worthwhile until you've actually measured it.

All I'm saying is that it is a lot of work to do to get it to a point where
a proposal has a decent chance of succeeding (IMHO).  If you are
volunteering to do it, I say go for it!
--=20
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

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

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

<div dir=3D"ltr">On 18 October 2014 01:41, David Krauss <span dir=3D"ltr">&=
lt;<a href=3D"mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</=
a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quot=
e"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><br><=
div><span class=3D""><div>You can get phenomenal performance by tuning a pr=
ogram to use a few string arenas without interleaving. The bytes recovered =
by an eager shrink-to-fit operation on the last allocation are going to be =
in L1 cache, and they=E2=80=99re the next to get allocated.<br></div></span=
></div></div></blockquote><div><br></div><div>Oh, sure.</div><div>=C2=A0</d=
iv><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><div>=
<div><br></div><div>How much improvement to everyday programs, when shrink-=
to-fit is enabled with malloc? Maybe not much. But that=E2=80=99s only one =
side of the argument. It=E2=80=99s still worthwhile to enable better perfor=
mance in fast allocators with proper support. Right now, the allocator gets=
 coupled unnecessarily to the algorithm because this one generic interface =
is missing.</div></div></div></blockquote><div><br></div><div>You cannot sa=
y it is worthwhile until you&#39;ve actually measured it.</div><div><br></d=
iv><div>All I&#39;m saying is that it is a lot of work to do to get it to a=
 point where a proposal has a decent chance of succeeding (IMHO).=C2=A0 If =
you are volunteering to do it, I say go for it!</div></div>-- <br>=C2=A0Nev=
in &quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverl=
ord.com" target=3D"_blank">nevin@eviloverlord.com</a>&gt;=C2=A0 (847) 691-1=
404
</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 />

--047d7bfced1cd04b370505acff91--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 18 Oct 2014 15:08:29 +0800
Raw View
--Apple-Mail=_CDD58B33-5204-4ADE-991F-2530C4B11055
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-10-18, at 2:57 PM, Nevin Liber <nevin@eviloverlord.com> wrote:

> On 18 October 2014 01:41, David Krauss <potswa@gmail.com> wrote:
>=20
> You can get phenomenal performance by tuning a program to use a few strin=
g arenas without interleaving. The bytes recovered by an eager shrink-to-fi=
t operation on the last allocation are going to be in L1 cache, and they're=
 the next to get allocated.
>=20
> Oh, sure.
> =20
>=20
> How much improvement to everyday programs, when shrink-to-fit is enabled =
with malloc? Maybe not much. But that's only one side of the argument. It's=
 still worthwhile to enable better performance in fast allocators with prop=
er support. Right now, the allocator gets coupled unnecessarily to the algo=
rithm because this one generic interface is missing.
>=20
> You cannot say it is worthwhile until you've actually measured it.

I'm only saying that such parsing/generation strategies already exist (as y=
ou seem to acknowledge) and the library should encourage the allocator to b=
e factored apart from the handling of content.

> All I'm saying is that it is a lot of work to do to get it to a point whe=
re a proposal has a decent chance of succeeding (IMHO).  If you are volunte=
ering to do it, I say go for it!

I guess it'll go into the queue :P

Hopefully someone else will attempt, they'll post here first, and I'll infl=
uence them not to be too ambitious or specific but to prioritize the essent=
ials.

--=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=_CDD58B33-5204-4ADE-991F-2530C4B11055
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;10&ndash;18, at 2:57 PM, Nevin Liber &lt;<a href=3D"mailto:nevin@evil=
overlord.com">nevin@eviloverlord.com</a>&gt; wrote:</div><br class=3D"Apple=
-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr">On 18 Octo=
ber 2014 01:41, David Krauss <span dir=3D"ltr">&lt;<a href=3D"mailto:potswa=
@gmail.com" target=3D"_blank">potswa@gmail.com</a>&gt;</span> wrote:<br><di=
v class=3D"gmail_extra"><div class=3D"gmail_quote"><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div style=3D"word-wrap:break-word"><br><div><span class=3D"">You ca=
n get phenomenal performance by tuning a program to use a few string arenas=
 without interleaving. The bytes recovered by an eager shrink-to-fit operat=
ion on the last allocation are going to be in L1 cache, and they&rsquo;re t=
he next to get allocated.<br></span></div></div></blockquote><div><br></div=
><div>Oh, sure.</div><div>&nbsp;</div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div s=
tyle=3D"word-wrap:break-word"><div><br></div><div>How much improvement to e=
veryday programs, when shrink-to-fit is enabled with malloc? Maybe not much=
.. But that&rsquo;s only one side of the argument. It&rsquo;s still worthwhi=
le to enable better performance in fast allocators with proper support. Rig=
ht now, the allocator gets coupled unnecessarily to the algorithm because t=
his one generic interface is missing.</div></div></blockquote><div><br></di=
v><div>You cannot say it is worthwhile until you've actually measured it.</=
div></div></div></div></blockquote><div><br></div><div>I&rsquo;m only sayin=
g that such parsing/generation strategies already exist (as you seem to ack=
nowledge) and the library should encourage the allocator to be factored apa=
rt from the handling of content.</div><br><blockquote type=3D"cite"><div di=
r=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div>All I'=
m saying is that it is a lot of work to do to get it to a point where a pro=
posal has a decent chance of succeeding (IMHO).&nbsp; If you are volunteeri=
ng to do it, I say go for it!</div></div></div></div></blockquote><div><br>=
</div><div>I guess it&rsquo;ll go into the queue :P</div><div><br></div><di=
v>Hopefully someone else will attempt, they&rsquo;ll post here first, and I=
&rsquo;ll influence them not to be too ambitious or specific but to priorit=
ize the essentials.</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=_CDD58B33-5204-4ADE-991F-2530C4B11055--

.


Author: contact@ncomputers.org
Date: Sat, 18 Oct 2014 00:13:04 -0700 (PDT)
Raw View
------=_Part_1745_799063238.1413616384568
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

David,

That=E2=80=99s why my suggestion is to focus on the generic Allocator conce=
pt, not=20
> on std::allocator.


Is *std::allocator* the responsable of allocate memory with the new=20
operator? Or is the "generic allocator" that you mention?

May I know better how would this interface be?

It=E2=80=99s still worthwhile to enable better performance in fast allocato=
rs with=20
> proper support.


I agree with you. I think that, fast allocators search better performance.

http://ncomputers.org

El s=C3=A1bado, 18 de octubre de 2014 01:42:01 UTC-5, David Krauss escribi=
=C3=B3:
>
>
> On 2014=E2=80=9310=E2=80=9318, at 2:23 PM, Nevin Liber <ne...@eviloverlor=
d.com=20
> <javascript:>> wrote:
>
> But malloc is typically in the domain of C and the OS.  On some systems=
=20
> for instance, you can intercept the malloc calls and replace them.  It is=
=20
> not trivial to add a reallocate-in-place facility that remains compatible=
=20
> with all these real world malloc implementations.
>
>
> That=E2=80=99s why my suggestion is to focus on the generic Allocator con=
cept, not=20
> on std::allocator.
>
> To properly take advantage of this, you need to change vector, allocators=
=20
> and malloc.  Now, given that most programs interleave allocations made in=
=20
> different objects (think about a vector<string>, for instance), you then=
=20
> have to benchmark your implementation to show under what circumstances it=
=20
> is a clear win for adding all this complexity.
>
>
> You can get phenomenal performance by tuning a program to use a few strin=
g=20
> arenas without interleaving. The bytes recovered by an eager shrink-to-fi=
t=20
> operation on the last allocation are going to be in L1 cache, and they=E2=
=80=99re=20
> the next to get allocated.
>
> How much improvement to everyday programs, when shrink-to-fit is enabled=
=20
> with malloc? Maybe not much. But that=E2=80=99s only one side of the argu=
ment. It=E2=80=99s=20
> still worthwhile to enable better performance in fast allocators with=20
> proper support. Right now, the allocator gets coupled unnecessarily to th=
e=20
> algorithm because this one generic interface is missing.
>

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

<div dir=3D"ltr">David,<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8=
ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D=
"gmail_quote">That=E2=80=99s why my suggestion is to focus on the generic A=
llocator concept, not on <font face=3D"Courier">std::allocator</font>.</blo=
ckquote><div><br>Is <b>std::allocator</b> the responsable of allocate memor=
y with the new operator? Or is the "generic allocator" that you mention?<br=
><br>May I know better how would this interface be?<br><br><blockquote styl=
e=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); =
padding-left: 1ex;" class=3D"gmail_quote">It=E2=80=99s still worthwhile to =
enable better performance in fast allocators with proper support.</blockquo=
te><div><br>I agree with you. I think that, fast allocators search better p=
erformance.<br><br><a href=3D"http://ncomputers.org">http://ncomputers.org<=
/a><br></div></div><br>El s=C3=A1bado, 18 de octubre de 2014 01:42:01 UTC-5=
, David Krauss escribi=C3=B3:<blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><=
div style=3D"word-wrap:break-word"><br><div><div>On 2014=E2=80=9310=E2=80=
=9318, at 2:23 PM, Nevin Liber &lt;<a href=3D"javascript:" target=3D"_blank=
" gdf-obfuscated-mailto=3D"M8gY1gYjnl4J" onmousedown=3D"this.href=3D'javasc=
ript:';return true;" onclick=3D"this.href=3D'javascript:';return true;">ne.=
...@eviloverlord.com</a>&gt; wrote:</div><br><blockquote type=3D"cite"><div =
class=3D"gmail_quote" style=3D"font-family:Helvetica;font-size:12px;font-st=
yle:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;lin=
e-height:normal;text-align:start;text-indent:0px;text-transform:none;white-=
space:normal;word-spacing:0px"><div>But malloc is typically in the domain o=
f C and the OS.&nbsp; On some systems for instance, you can intercept the m=
alloc calls and replace them.&nbsp; It is not trivial to add a reallocate-i=
n-place facility that remains compatible with all these real world malloc i=
mplementations.</div></div></blockquote><div><br></div><div>That=E2=80=99s =
why my suggestion is to focus on the generic Allocator concept, not on <fon=
t face=3D"Courier">std::allocator</font>.</div><br><blockquote type=3D"cite=
"><div class=3D"gmail_quote" style=3D"font-family:Helvetica;font-size:12px;=
font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:nor=
mal;line-height:normal;text-align:start;text-indent:0px;text-transform:none=
;white-space:normal;word-spacing:0px"><div>To properly take advantage of th=
is, you need to change vector, allocators and malloc.&nbsp; Now, given that=
 most programs interleave allocations made in different objects (think abou=
t a vector&lt;string&gt;, for instance), you then have to benchmark your im=
plementation to show under what circumstances it is a clear win for adding =
all this complexity.</div></div></blockquote><div><br></div><div>You can ge=
t phenomenal performance by tuning a program to use a few string arenas wit=
hout interleaving. The bytes recovered by an eager shrink-to-fit operation =
on the last allocation are going to be in L1 cache, and they=E2=80=99re the=
 next to get allocated.</div><div><br></div><div>How much improvement to ev=
eryday programs, when shrink-to-fit is enabled with malloc? Maybe not much.=
 But that=E2=80=99s only one side of the argument. It=E2=80=99s still worth=
while to enable better performance in fast allocators with proper support. =
Right now, the allocator gets coupled unnecessarily to the algorithm becaus=
e this one generic interface is missing.</div></div></div></blockquote></di=
v>

<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_1745_799063238.1413616384568--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 18 Oct 2014 15:22:50 +0800
Raw View
--Apple-Mail=_5E9A5AC6-1726-4BA8-ACE9-F91BEBA2E1EE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-10-18, at 3:13 PM, contact@ncomputers.org wrote:

> David,
>=20
> That's why my suggestion is to focus on the generic Allocator concept, no=
t on std::allocator.
>=20
> Is std::allocator the responsable of allocate memory with the new operato=
r? Or is the "generic allocator" that you mention?

std::allocator calls (specifically) ::operator new calls (in practice) mall=
oc.

> May I know better how would this interface be?

Anyone can write a custom allocator, following the rules of [allocator.requ=
irements] =A717.6.3.5. It will only be used when specifically instantiated,=
 never by the default std::string, std::vector<T>, etc.

> It's still worthwhile to enable better performance in fast allocators wit=
h proper support.
>=20
> I agree with you. I think that, fast allocators search better performance=
..

Custom allocators improve performance at a huge cost in convenience :/ . As=
 I mentioned to Nevin, my take on this issue isn't really about improving p=
erformance of existing programs, but to improve portability and modularity =
of certain program architectures. Maybe even help bring high-performance li=
braries to the masses, but still, porting a program to use custom allocator=
s is a major hurdle which isn't going away.

--=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=_5E9A5AC6-1726-4BA8-ACE9-F91BEBA2E1EE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;10&ndash;18, at 3:13 PM, <a href=3D"mailto:contact@ncomputers.org">co=
ntact@ncomputers.org</a> wrote:</div><br class=3D"Apple-interchange-newline=
"><blockquote type=3D"cite"><div style=3D"font-family: Helvetica; font-size=
: 12px; font-style: normal; font-variant: normal; font-weight: normal; lett=
er-spacing: normal; line-height: normal; orphans: auto; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir=3D"ltr">David,=
<br><br><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8e=
x; border-left-width: 1px; border-left-style: solid; border-left-color: rgb=
(204, 204, 204); padding-left: 1ex;">That&rsquo;s why my suggestion is to f=
ocus on the generic Allocator concept, not on<span class=3D"Apple-converted=
-space">&nbsp;</span><font face=3D"Courier">std::allocator</font>.</blockqu=
ote><div><br>Is<span class=3D"Apple-converted-space">&nbsp;</span><b>std::a=
llocator</b><span class=3D"Apple-converted-space">&nbsp;</span>the responsa=
ble of allocate memory with the new operator? Or is the "generic allocator"=
 that you mention?<br></div></div></div></blockquote><div><br></div><div><f=
ont face=3D"Courier">std::allocator</font> calls (specifically) <font face=
=3D"Courier">::operator new</font> calls (in practice) <font face=3D"Courie=
r">malloc</font>.</div><br><blockquote type=3D"cite"><div style=3D"font-fam=
ily: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; orphans: =
auto; text-align: start; text-indent: 0px; text-transform: none; white-spac=
e: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;=
"><div dir=3D"ltr"><div>May I know better how would this interface be?<br><=
/div></div></div></blockquote><div><br></div><div>Anyone can write a custom=
 allocator, following the rules of [allocator.requirements] =A717.6.3.5. It=
 will only be used when specifically instantiated, never by the default <fo=
nt face=3D"Courier">std::string</font>, <font face=3D"Courier">std::vector&=
lt;T&gt;</font>, etc.</div><br><blockquote type=3D"cite"><div style=3D"font=
-family: Helvetica; font-size: 12px; font-style: normal; font-variant: norm=
al; font-weight: normal; letter-spacing: normal; line-height: normal; orpha=
ns: auto; text-align: start; text-indent: 0px; text-transform: none; white-=
space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: =
0px;"><div dir=3D"ltr"><div><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; bo=
rder-left-color: rgb(204, 204, 204); padding-left: 1ex;">It&rsquo;s still w=
orthwhile to enable better performance in fast allocators with proper suppo=
rt.</blockquote><div><br>I agree with you. I think that, fast allocators se=
arch better performance.<br></div></div></div></div></blockquote></div><br>=
<div>Custom allocators improve performance at a huge cost in convenience :/=
 . As I mentioned to Nevin, my take on this issue isn&rsquo;t really about =
improving performance of existing programs, but to improve portability and =
modularity of certain program architectures. Maybe even help bring high-per=
formance libraries to the masses, but still, porting a program to use custo=
m allocators is a major hurdle which isn&rsquo;t going away.</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=_5E9A5AC6-1726-4BA8-ACE9-F91BEBA2E1EE--

.


Author: contact@ncomputers.org
Date: Sat, 18 Oct 2014 00:46:41 -0700 (PDT)
Raw View
------=_Part_1654_1184240953.1413618401220
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


>
> Hopefully someone else will attempt, they=E2=80=99ll post here first, and=
 I=E2=80=99ll=20
> influence them not to be too ambitious or specific but to prioritize the=
=20
> essentials.
>

Yes someone will attempt it! I've talked about it with my team. If we had=
=20
more free time, we would start to write it together just now! Unfortunately=
=20
we don't have enough time and it would be the first paper for the ISO/ANSI=
=20
C++, which I wrote, but I can learn a lot of you, collect the enough=20
experience and especially, to learn how to argue front the committee to=20
make the proposal to have success :D I'll also rejoice, if I find someone=
=20
who wants to work together to achieve this standardization.

Seen from my point of view, it is obvious that a *new*[size] operator=20
should have a *delete*[size] operator as counterpart.

std::allocator calls (specifically) ::operator new calls (in practice)=20
> malloc.
>

A professor taught me that the new operator only use malloc with glibc :(

Custom allocators improve performance at a huge cost in convenience :/ . As=
=20
> I mentioned to Nevin, my take on this issue isn=E2=80=99t really about im=
proving=20
> performance of existing programs, but to improve portability and modulari=
ty=20
> of certain program architectures. Maybe even help bring high-performance=
=20
> libraries to the masses, but still, porting a program to use custom=20
> allocators is a major hurdle which isn=E2=80=99t going away.


I understand it. Our goal is to allow to shrink arrays allocated by the new=
=20
operator and that every compiler support it.

 std::allocator calls (specifically) ::operator new calls (in practice)=20
> malloc.


If the *::operator new*  calls (in practice) *malloc*, is it theoretically=
=20
possible to use=20

*realloc?*We've used *realloc* for arrays allocated by the *new* operator,=
=20
it works with glibc - GCC and Visual C++, but someone told us, that it is=
=20
disallowed

*. Is it?**Other fact that is important to mention, is that the only=20
possible way to call an overloaded delete[] operator with specific=20
arguments is calling it explicitly, what causes to make very hard (or even=
=20
impossible) to support objects with destructors, as described *below.

*That's why we suggest this improvement to the delete[] operator. *At least=
=20
i*t should accept a call like *the following, what is the same what we=20
purpose



*:delete (argument) [] pointer;*Additional information (Can someone answer=
=20
one of the questions?):

We're trying to overload the *delete[]* operator to achieve shrinkable=20
> oriented to objects arrays=20
> <http://ncomputers.org/content/code.php?src=3Dsuggestions/shrink%20arrays=
%20cpp>
> .
>
> It works fine with data types without specific destructor.
>
> When the data type has a specified destructor, the *new[]* operator needs=
=20
> extra bytes.
>
> Could you help us please to answer these questions?
>
>    1. Why does the *new[]* operator require extra bytes for data types=20
>    with specific destructor?
>    2. Will always the *new[]* operator request these bytes or is it=20
>    library dependent?
>    3. Is it possible to know if the data type has a specific destructor=
=20
>    with an *if statement*?
>
> The code should throw an unhandled exception when it tries to shrink the=
=20
> array of B's.
>
#include<cstdlib>
#include<iostream>
using namespace std;

void*operator new[](size_t s){
    cout<<"Block size: "<<s<<endl;
    return malloc(s);
}
void operator delete[](void*p){
    free(p);
}
void operator delete[](void*p,size_t s){
    //Is it possible to know if the data type has a specific destructor?
    bool destructor=3D0;
    if(destructor){
        p=3D(char*)p-8,s+=3D8;
    }
    cout<<"New block size: "<<s<<endl;
    if(realloc(p,s)!=3Dp)throw 0;
}

struct A{
    char a;

    A():a(0){}
    ~A()=3Ddefault;
};

struct B{
    char b;

    B():b(0){}
    ~B(){}
};

int main(){
    unsigned S=3D10,s=3D4;
    cout<<"Creating "<<S<<" A's"<<endl;
    A*a=3Dnew A[S];
    cout<<"Creating "<<S<<" B's"<<endl;
    B*b=3Dnew B[S];
    cout<<"Shrinking A to "<<s<<" elements"<<endl;
    operator delete[](a,sizeof(A)*s);
    cout<<"Shrinking B to "<<s<<" elements"<<endl;
    operator delete[](b,sizeof(B)*s);
    cout<<"Deleting A and B"<<endl;
    delete[]b,delete[]a;
    return 0;
}



El s=C3=A1bado, 18 de octubre de 2014 02:08:40 UTC-5, David Krauss escribi=
=C3=B3:
>
>
> On 2014=E2=80=9310=E2=80=9318, at 2:57 PM, Nevin Liber <ne...@eviloverlor=
d.com=20
> <javascript:>> wrote:
>
> On 18 October 2014 01:41, David Krauss <pot...@gmail.com <javascript:>>=
=20
> wrote:
>
>>
>> You can get phenomenal performance by tuning a program to use a few=20
>> string arenas without interleaving. The bytes recovered by an eager=20
>> shrink-to-fit operation on the last allocation are going to be in L1 cac=
he,=20
>> and they=E2=80=99re the next to get allocated.
>>
>
> Oh, sure.
> =20
>
>>
>> How much improvement to everyday programs, when shrink-to-fit is enabled=
=20
>> with malloc? Maybe not much. But that=E2=80=99s only one side of the arg=
ument. It=E2=80=99s=20
>> still worthwhile to enable better performance in fast allocators with=20
>> proper support. Right now, the allocator gets coupled unnecessarily to t=
he=20
>> algorithm because this one generic interface is missing.
>>
>
> You cannot say it is worthwhile until you've actually measured it.
>
>
> I=E2=80=99m only saying that such parsing/generation strategies already e=
xist (as=20
> you seem to acknowledge) and the library should encourage the allocator t=
o=20
> be factored apart from the handling of content.
>
> All I'm saying is that it is a lot of work to do to get it to a point=20
> where a proposal has a decent chance of succeeding (IMHO).  If you are=20
> volunteering to do it, I say go for it!
>
>
> I guess it=E2=80=99ll go into the queue :P
>
> Hopefully someone else will attempt, they=E2=80=99ll post here first, and=
 I=E2=80=99ll=20
> influence them not to be too ambitious or specific but to prioritize the=
=20
> essentials.
>

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

<div dir=3D"ltr"><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-lef=
t: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">=
Hopefully someone else will attempt, they=E2=80=99ll post here first, and I=
=E2=80=99ll=20
influence them not to be too ambitious or specific but to prioritize the
 essentials.<br></blockquote><div><br>Yes someone will attempt it! I've tal=
ked about it with my team. If we had more free time, we would start to writ=
e it together just now! Unfortunately we don't have enough time and it woul=
d be the first paper for the ISO/ANSI C++, which I wrote, but I can learn a=
 lot of you, collect the enough experience and especially, to learn how to =
argue front the committee to make the proposal to have success :D I'll also=
 rejoice, if I find someone who wants to work together to achieve this stan=
dardization.<br><br>Seen from my point of view, it is obvious that a <b>new=
</b>[size] operator should have a <b>delete</b>[size] operator as counterpa=
rt.<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px=
 solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote"><font =
face=3D"Courier">std::allocator</font> calls (specifically) <font face=3D"C=
ourier">::operator new</font> calls (in practice) <font face=3D"Courier">ma=
lloc</font>.<br></blockquote><div><br>A professor taught me that the new op=
erator only use malloc with glibc :(<br><br><blockquote style=3D"margin: 0p=
x 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1=
ex;" class=3D"gmail_quote">Custom allocators improve performance at a huge =
cost in convenience :/ .
 As I mentioned to Nevin, my take on this issue isn=E2=80=99t really about=
=20
improving performance of existing programs, but to improve portability=20
and modularity of certain program architectures. Maybe even help bring=20
high-performance libraries to the masses, but still, porting a program=20
to use custom allocators is a major hurdle which isn=E2=80=99t going away.<=
/blockquote><div><br>I understand it. Our goal is to allow to shrink arrays=
 allocated by the new operator and that every compiler support it.<br><br><=
blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(2=
04, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">&nbsp;<font face=
=3D"Courier">std::allocator</font> calls (specifically) <font face=3D"Couri=
er">::operator new</font> calls (in practice) <font face=3D"Courier">malloc=
</font>.</blockquote><div><br>If the <b>::operator new</b>&nbsp; calls (in =
practice) <b>malloc</b>, is it theoretically possible to use <b>realloc?<br=
><br></b>We've used <b>realloc</b> for arrays allocated by the <b>new</b> o=
perator, it works with glibc - GCC and Visual C++, but someone told us, tha=
t it is disallowed<b>. Is it?<br><br></b><b><span style=3D"font-weight: nor=
mal;">Other fact that is important to mention, is that the only possible wa=
y to call an overloaded delete[] operator with specific arguments is callin=
g it explicitly, what causes to make very hard (or even impossible) to supp=
ort objects with destructors, as described </span></b><span style=3D"font-w=
eight: normal;">below.</span><b><span style=3D"font-weight: normal;"><br><b=
r>That's why we suggest this improvement to the <b>delete[]</b> operator. <=
/span></b><span style=3D"font-weight: normal;">At least i</span><b><span st=
yle=3D"font-weight: normal;">t should accept a call like </span></b><span s=
tyle=3D"font-weight: normal;">the following, what is the same what we purpo=
se</span><b><span style=3D"font-weight: normal;">:<br><br></span><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
 style=3D"font-weight: normal;"><span style=3D"color: #008;" class=3D"style=
d-by-prettify">delete</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">argumen=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">[]</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> pointer</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span></span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span></div></code></div><br></b>A=
dditional information (Can someone answer one of the questions?):<br><br><b=
lockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(20=
4, 204, 204); padding-left: 1ex;" class=3D"gmail_quote"><p>We're trying to =
overload the <strong>delete[]</strong> operator to achieve <a href=3D"http:=
//ncomputers.org/content/code.php?src=3Dsuggestions/shrink%20arrays%20cpp" =
rel=3D"nofollow">shrinkable oriented to objects arrays</a>.</p>

<p>It works fine with data types without specific destructor.</p>

<p>When the data type has a specified destructor, the <strong>new[]</strong=
> operator needs extra bytes.</p>

<p>Could you help us please to answer these questions?</p>

<ol><li>Why does the <strong>new[]</strong> operator require extra bytes fo=
r data types with specific destructor?</li><li>Will always the <strong>new[=
]</strong> operator request these bytes or is it library dependent?</li><li=
>Is it possible to know if the data type has a specific destructor with an =
<strong>if statement</strong>?</li></ol>

<p>The code should throw an unhandled exception when it tries to shrink the=
 array of B's.</p></blockquote>

<pre style=3D"" class=3D"lang-cpp prettyprint prettyprinted"><code><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap:=
 break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><pr=
e style=3D"" class=3D"lang-cpp prettyprint prettyprinted"><code><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;cstdlib&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;iostream&gt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">namespace</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">void</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">*</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
operator</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">new</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">[](</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">size_t s</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">){</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; cout</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify">"Block size: "</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">s</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> malloc</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">s</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">delete</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">[](</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">void</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">p</span><span style=3D"color: #660;" class=3D"styled-by-prettify">){</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; free</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">p</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">operator</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
delete</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[](<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">p</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">size_t s</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; </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">//Is it possible to know if the data type has =
a specific destructor?</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> destructor</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">0</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; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">if=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">destructor</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">){</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &n=
bsp; p</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D(=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">*)</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">p</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">8</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">s</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">+=3D</span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
8</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; =
</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; &nbsp; c=
out</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span style=3D"color: #080;" class=3D"styled-by-prettify">"New bloc=
k size: "</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">s</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">endl</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">if</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">realloc</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">p</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">s</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)=
!=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">throw</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</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-prett=
ify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
A</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; =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; A</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">():</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">a</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;"=
 class=3D"styled-by-prettify">0</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; </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">~</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">A</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">()=3D</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>default</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> B</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">char</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br>&nbsp; &nbsp; B</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">():</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
0</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=
; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">~</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">B</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(){}</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><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> main</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(){</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">unsigned</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> S</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #066;" class=3D"styled-by-prettify">1=
0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">s</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">4</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; cout</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #0=
80;" class=3D"styled-by-prettify">"Creating "</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">S</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">" A's"</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>&nbsp; &nbsp; A</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">new</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">S</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; cout</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #080;=
" class=3D"styled-by-prettify">"Creating "</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">S</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #080;" class=3D"s=
tyled-by-prettify">" B's"</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>&nbsp; &nbsp; B</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">b<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">new</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> B</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">S</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">];</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>&nbsp; &nbsp; cout</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #080;" cla=
ss=3D"styled-by-prettify">"Shrinking A to "</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">s</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">" elements"</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">endl</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">operator</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">delete</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">[](</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">A</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">)*</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">s</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; cout</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&lt;&lt;</span><span style=3D"color: #080;" class=3D"sty=
led-by-prettify">"Shrinking B to "</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">s</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;&lt;</span><span style=3D"color: #080;" class=3D"styled-=
by-prettify">" elements"</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">operator</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">delete=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[](</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">b</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">B</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)*</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">s</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp; &nbsp; cout</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&lt;&lt;</span><span style=3D"color: #080;" class=3D"styled-by-prettif=
y">"Deleting A and B"</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&n=
bsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">delete</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[]=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">b</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">delete</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">[]</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">a</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></co=
de></pre></div></code></div><br><span class=3D"pun"></span></code> <br></pr=
e></div></div></div></div>El s=C3=A1bado, 18 de octubre de 2014 02:08:40 UT=
C-5, David Krauss escribi=C3=B3:<blockquote class=3D"gmail_quote" style=3D"=
margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;=
"><div style=3D"word-wrap:break-word"><br><div><div>On 2014=E2=80=9310=E2=
=80=9318, at 2:57 PM, Nevin Liber &lt;<a href=3D"javascript:" target=3D"_bl=
ank" gdf-obfuscated-mailto=3D"-k4nYa8EZ2wJ" onmousedown=3D"this.href=3D'jav=
ascript:';return true;" onclick=3D"this.href=3D'javascript:';return true;">=
ne...@eviloverlord.com</a>&gt; wrote:</div><br><blockquote type=3D"cite"><d=
iv dir=3D"ltr">On 18 October 2014 01:41, David Krauss <span dir=3D"ltr">&lt=
;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"-k4nYa8=
EZ2wJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"th=
is.href=3D'javascript:';return true;">pot...@gmail.com</a>&gt;</span> wrote=
:<br><div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div st=
yle=3D"word-wrap:break-word"><br><div><span>You can get phenomenal performa=
nce by tuning a program to use a few string arenas without interleaving. Th=
e bytes recovered by an eager shrink-to-fit operation on the last allocatio=
n are going to be in L1 cache, and they=E2=80=99re the next to get allocate=
d.<br></span></div></div></blockquote><div><br></div><div>Oh, sure.</div><d=
iv>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break=
-word"><div><br></div><div>How much improvement to everyday programs, when =
shrink-to-fit is enabled with malloc? Maybe not much. But that=E2=80=99s on=
ly one side of the argument. It=E2=80=99s still worthwhile to enable better=
 performance in fast allocators with proper support. Right now, the allocat=
or gets coupled unnecessarily to the algorithm because this one generic int=
erface is missing.</div></div></blockquote><div><br></div><div>You cannot s=
ay it is worthwhile until you've actually measured it.</div></div></div></d=
iv></blockquote><div><br></div><div>I=E2=80=99m only saying that such parsi=
ng/generation strategies already exist (as you seem to acknowledge) and the=
 library should encourage the allocator to be factored apart from the handl=
ing of content.</div><br><blockquote type=3D"cite"><div dir=3D"ltr"><div><d=
iv class=3D"gmail_quote"><div>All I'm saying is that it is a lot of work to=
 do to get it to a point where a proposal has a decent chance of succeeding=
 (IMHO).&nbsp; If you are volunteering to do it, I say go for it!</div></di=
v></div></div></blockquote><div><br></div><div>I guess it=E2=80=99ll go int=
o the queue :P</div><div><br></div><div>Hopefully someone else will attempt=
, they=E2=80=99ll post here first, and I=E2=80=99ll influence them not to b=
e too ambitious or specific but to prioritize the essentials.</div></div></=
div></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_1654_1184240953.1413618401220--

.


Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Mon, 20 Oct 2014 22:10:14 +0330
Raw View
--047d7bd9170af70afb0505df0d91
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

IMHO developing your own allocator/container system is  better and easier
than trying to change the behavior of new/delete; It is already complicated
enough and if not for the sake of existing libs and codes relying on
new/delete, I wouldn't use them except for the case of placement new. The
new/delete predate templates and therefor lack proper facilities to store
customized run-time type info.
IMHO variadic templates and constructor forwarding, facilitate deriving
tools that encourage deprecation of naked use of new/delete.
Someday when you get the opportunity to refactor/optimize your personal
lib, a good proposal becomes possible. It takes more time but less risk.

regard,
FM.

2014-10-18 9:32 GMT+03:30 <contact@ncomputers.org>:

> David, thank you very much for your answer!
>
> it shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t suppor=
t it.
>
>
> I agree with it.
>
>  There have been several, but I=E2=80=99m not digging for the others righ=
t now.
>
>
> I understand it. So far my experience says, it is easier to propose
> something new, than that the proposals become accepted. We're excepting
> that it could even require more than ten years,
> that the *std::allocator* become standardized to allow in-place resizing.
>
> One of our objectives is to share this idea for the improvement of the
> *delete[]* operator, so programmers around the world can know it and the
> right ones, will achieve to standardize such proposals or similars.
>
> The codes that we're writting could free some megabytes of useless data
> and we're writting in them (commented):
>
> //Awaiting shrinkable arrays:
> delete [oldSize - newSize] pointer;
>
> So, when shrinkable arrays are possible, someone will uncomment the lines
> and those megabytes of waste can be freed.
>
> Unfortunately we don't have neither the necessary experience nor the time
> to write a paper, which has high possibilities to be accepted and
> standardized, but how do you think, that we can contribute to support eve=
ry
> reasonable proposal of what you call:
>
> C++ adaptation of realloc
>>
>
> And to make programmers consider the possibility of having a logical
> *new[*size*]* and *delete[*size*]* operators?
>
> ncomputers.org
>
> El s=C3=A1bado, 18 de octubre de 2014 00:43:16 UTC-5, David Krauss escrib=
i=C3=B3:
>
>>
>> On 2014=E2=80=9310=E2=80=9318, at 1:38 PM, con...@ncomputers.org wrote:
>>
>> Thank you very much for your time and your answer!
>>
>> I didn't understand exactly what you wrote:
>>
>> I=E2=80=99d think the functionality could be sliced off any existing mal=
loc.
>>>
>>
>> Nevin said that resizing malloc allocations would require a rewrite of
>> malloc. I think that it would not be a total rewrite, but only an
>> adaptation of code that should already exist for realloc. And anyway, it
>> shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t support =
it.
>>
>> I didn't understand this:
>>
>> N3495 looks completely different from the one proposal I recall with a
>>> C++ adaptation of realloc, which also had issues.
>>
>>
>> Which porposal is "C++ adaptation of realloc"?
>>
>> What did you want to express?
>>
>>
>> Anything that provides a capability to change the size of an allocation
>> without getting into realloc=E2=80=99s requirement of trivial copyabilit=
y, I=E2=80=99d
>> consider to be a C++ adaptation of realloc. There have been several, but
>> I=E2=80=99m not digging for the others right now.
>>
>  --

---
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
how am I supposed to end the twisted road of  your hair in the dark night??
unless the candle of your face does turn a lamp up on my way!!!

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

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

<div dir=3D"rtl"><div dir=3D"ltr">IMHO developing your own allocator/contai=
ner system is =C2=A0better and easier than trying to change the behavior of=
 new/delete; It is already complicated enough and if not for the sake of ex=
isting libs and codes relying on new/delete, I wouldn&#39;t use them except=
 for the case of placement new. The new/delete predate templates and theref=
or lack proper facilities to store customized run-time type info.</div><div=
 dir=3D"ltr">IMHO variadic templates and constructor forwarding, facilitate=
 deriving tools that encourage deprecation of naked use of new/delete.</div=
><div dir=3D"ltr">Someday when you get the opportunity to refactor/optimize=
 your personal lib, a good proposal becomes possible. It takes more time bu=
t less risk.</div><div dir=3D"ltr"><br></div><div>regard,</div><div>FM.</di=
v></div><div class=3D"gmail_extra"><div dir=3D"ltr"><br><div class=3D"gmail=
_quote">2014-10-18 9:32 GMT+03:30  <span dir=3D"ltr">&lt;<a href=3D"mailto:=
contact@ncomputers.org" target=3D"_blank">contact@ncomputers.org</a>&gt;</s=
pan>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex">David, thank you very much for your=
 answer!<span class=3D""><br><br><blockquote style=3D"margin:0px 0px 0px 0.=
8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class=3D"gmail=
_quote">it shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t =
support it.</blockquote></span><div><br>I agree with it.<span class=3D""><b=
r><br><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid r=
gb(204,204,204);padding-left:1ex" class=3D"gmail_quote">=C2=A0There have be=
en several, but I=E2=80=99m not digging for the others right now.</blockquo=
te></span><div><br>I understand it. So far my experience says, it is easier=
 to propose something new, than that the proposals become accepted. We&#39;=
re excepting that it could even require more than ten years, <br>that the <=
b>std::allocator</b> become standardized to allow in-place resizing.<br><br=
>One of our objectives is to share this idea for the improvement of the <b>=
delete[]</b> operator, so programmers around the world can know it and the =
right ones, will achieve to standardize such proposals or similars.<br><br>=
The codes that we&#39;re writting could free some megabytes of useless data=
 and we&#39;re writting in them (commented):<br><br><div style=3D"backgroun=
d-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;b=
order-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#800"=
>//Awaiting shrinkable arrays:</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#008">delete</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">[</span><span style=3D"color:#000">oldSize </spa=
n><span style=3D"color:#660">-</span><span style=3D"color:#000"> newSize</s=
pan><span style=3D"color:#660">]</span><span style=3D"color:#000"> pointer<=
/span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br></s=
pan></div></code></div><br>So, when shrinkable arrays are possible, someone=
 will uncomment the lines and those megabytes of waste can be freed.<br><br=
>Unfortunately we don&#39;t have neither the necessary experience nor the t=
ime to write a paper, which has high possibilities to be accepted and stand=
ardized, but how do you think, that we can contribute to support every reas=
onable proposal of what you call:<br><br><blockquote style=3D"margin:0px 0p=
x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class=
=3D"gmail_quote">C++ adaptation of realloc<br></blockquote><div><br>And to =
make programmers consider the possibility of having a logical <b>new[</b>si=
ze<b>]</b> and <b>delete[</b>size<b>]</b> operators?<br><br><a href=3D"http=
://ncomputers.org" target=3D"_blank">ncomputers.org</a><br></div></div></di=
v><br>El s=C3=A1bado, 18 de octubre de 2014 00:43:16 UTC-5, David Krauss es=
cribi=C3=B3:<div><div class=3D"h5"><blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div style=3D"word-wrap:break-word"><br><div><div>On 2014=E2=80=9310=E2=80=
=9318, at 1:38 PM, <a>con...@ncomputers.org</a> wrote:</div><br><blockquote=
 type=3D"cite"><div style=3D"font-family:Helvetica;font-size:12px;font-styl=
e:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-=
height:normal;text-align:start;text-indent:0px;text-transform:none;white-sp=
ace:normal;word-spacing:0px"><div dir=3D"ltr">Thank you very much for your =
time and your answer!<br><br>I didn&#39;t understand exactly what you wrote=
:<br><br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,2=
04,204);padding-left:1ex">I=E2=80=99d think the functionality could be slic=
ed off any existing malloc.<br></blockquote></div></div></blockquote><div><=
br></div><div>Nevin said that resizing malloc allocations would require a r=
ewrite of malloc. I think that it would not be a total rewrite, but only an=
 adaptation of code that should already exist for realloc. And anyway, it s=
houldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t support it.<=
/div><br><blockquote type=3D"cite"><div style=3D"font-family:Helvetica;font=
-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-=
spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-tra=
nsform:none;white-space:normal;word-spacing:0px"><div dir=3D"ltr"><div>I di=
dn&#39;t understand this:</div><div><br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:so=
lid;border-left-color:rgb(204,204,204);padding-left:1ex">N3495 looks comple=
tely different from the one proposal I recall with a C++ adaptation of real=
loc, which also had issues.</blockquote><div><br>Which porposal is &quot;C+=
+ adaptation of realloc&quot;?<br><br>What did you want to express?<br></di=
v></div></div></div></blockquote><div><br></div><div>Anything that provides=
 a capability to change the size of an allocation without getting into real=
loc=E2=80=99s requirement of trivial copyability, I=E2=80=99d consider to b=
e a C++ adaptation of realloc. There have been several, but I=E2=80=99m not=
 digging for the others right now.</div></div></div></blockquote></div></di=
v></blockquote></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></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr">=
how am I supposed to end the twisted road of=C2=A0 your hair in the dark ni=
ght??<br>unless the candle of your face does turn a lamp up on my way!!!<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 />

--047d7bd9170af70afb0505df0d91--

.


Author: contact@ncomputers.org
Date: Mon, 20 Oct 2014 12:15:19 -0700 (PDT)
Raw View
------=_Part_3554_1596231722.1413832520011
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thank you very much for your comment.

Someday when you get the opportunity to refactor/optimize your personal=20
> lib, a good proposal becomes possible. It takes more time but less risk.


This is a very good recommendation. Thank you for helping us!

I am trying to have an overloaded *delete[]* operator that accepts specific=
=20
arguments. Because the only way to call a *delete[]* operator with specific=
=20
arguments is explicitly, it loses the support for objects with destructor=
=20
<http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%205.=
cpp>.=20
I've almost achieved personal shrinkable arrays. This is the last=20
complication I have. Do you have any idea of how can we enable a sugar=20
syntactic call to an overloaded *delete[]* operator with specific=20
arguments: *delete* (argument)[] pointer like its counterpart *new*=20
(argument)[size]?

El lunes, 20 de octubre de 2014 13:40:55 UTC-5, Farid Mehrabi escribi=C3=B3=
:
>
> IMHO developing your own allocator/container system is  better and easier=
=20
> than trying to change the behavior of new/delete; It is already complicat=
ed=20
> enough and if not for the sake of existing libs and codes relying on=20
> new/delete, I wouldn't use them except for the case of placement new. The=
=20
> new/delete predate templates and therefor lack proper facilities to store=
=20
> customized run-time type info.
> IMHO variadic templates and constructor forwarding, facilitate deriving=
=20
> tools that encourage deprecation of naked use of new/delete.
> Someday when you get the opportunity to refactor/optimize your personal=
=20
> lib, a good proposal becomes possible. It takes more time but less risk.
>
> regard,
> FM.
>
> 2014-10-18 9:32 GMT+03:30 <con...@ncomputers.org <javascript:>>:
>
>> David, thank you very much for your answer!
>>
>> it shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t suppo=
rt it.
>>
>>
>> I agree with it.
>>
>>  There have been several, but I=E2=80=99m not digging for the others rig=
ht now.
>>
>>
>> I understand it. So far my experience says, it is easier to propose=20
>> something new, than that the proposals become accepted. We're excepting=
=20
>> that it could even require more than ten years,=20
>> that the *std::allocator* become standardized to allow in-place resizing=
..
>>
>> One of our objectives is to share this idea for the improvement of the=
=20
>> *delete[]* operator, so programmers around the world can know it and the=
=20
>> right ones, will achieve to standardize such proposals or similars.
>>
>> The codes that we're writting could free some megabytes of useless data=
=20
>> and we're writting in them (commented):
>>
>> //Awaiting shrinkable arrays:
>> delete [oldSize - newSize] pointer;
>>
>> So, when shrinkable arrays are possible, someone will uncomment the line=
s=20
>> and those megabytes of waste can be freed.
>>
>> Unfortunately we don't have neither the necessary experience nor the tim=
e=20
>> to write a paper, which has high possibilities to be accepted and=20
>> standardized, but how do you think, that we can contribute to support ev=
ery=20
>> reasonable proposal of what you call:
>>
>> C++ adaptation of realloc
>>>
>>
>> And to make programmers consider the possibility of having a logical=20
>> *new[*size*]* and *delete[*size*]* operators?
>>
>> ncomputers.org
>>
>> El s=C3=A1bado, 18 de octubre de 2014 00:43:16 UTC-5, David Krauss escri=
bi=C3=B3:
>>
>>>
>>> On 2014=E2=80=9310=E2=80=9318, at 1:38 PM, con...@ncomputers.org wrote:
>>>
>>> Thank you very much for your time and your answer!
>>>
>>> I didn't understand exactly what you wrote:
>>>
>>> I=E2=80=99d think the functionality could be sliced off any existing ma=
lloc.
>>>>
>>>
>>> Nevin said that resizing malloc allocations would require a rewrite of=
=20
>>> malloc. I think that it would not be a total rewrite, but only an=20
>>> adaptation of code that should already exist for realloc. And anyway, i=
t=20
>>> shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t support=
 it.
>>>
>>> I didn't understand this:
>>>
>>> N3495 looks completely different from the one proposal I recall with a=
=20
>>>> C++ adaptation of realloc, which also had issues.
>>>
>>>
>>> Which porposal is "C++ adaptation of realloc"?
>>>
>>> What did you want to express?
>>>
>>>
>>> Anything that provides a capability to change the size of an allocation=
=20
>>> without getting into realloc=E2=80=99s requirement of trivial copyabili=
ty, I=E2=80=99d=20
>>> consider to be a C++ adaptation of realloc. There have been several, bu=
t=20
>>> I=E2=80=99m not digging for the others right now.
>>>
>>  --=20
>
> ---=20
> You received this message because you are subscribed to the Google Groups=
=20
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
=20
> email to std-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> Visit this group at=20
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
> --=20
> how am I supposed to end the twisted road of  your hair in the dark night=
??
> unless the candle of your face does turn a lamp up on my way!!!
> =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_3554_1596231722.1413832520011
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thank you very much for your comment.<br><br><blockquote s=
tyle=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204=
); padding-left: 1ex;" class=3D"gmail_quote">Someday when you get the oppor=
tunity to refactor/optimize your personal=20
lib, a good proposal becomes possible. It takes more time but less risk.</b=
lockquote><div><br>This is a very good recommendation. Thank you for helpin=
g us!<br><br>I am trying to have an overloaded <span style=3D"font-family: =
courier new,monospace;"><b>delete[]</b></span> operator that accepts specif=
ic arguments. Because the only way to call a <span style=3D"font-family: co=
urier new,monospace;"><b>delete[]</b></span> operator with specific argumen=
ts is explicitly, it <a href=3D"http://ncomputers.org/content/code.php?src=
=3Dexamples/shrink%20arrays%205.cpp">loses the support for objects with des=
tructor</a>. I've almost achieved personal shrinkable arrays. This is the l=
ast complication I have. Do you have any idea of how can we enable a sugar =
syntactic call to an overloaded <span style=3D"font-family: courier new,mon=
ospace;"><b>delete[]</b></span> operator with specific arguments: <code cla=
ss=3D"code"><span style=3D"background-color: rgb(207, 226, 243);"><span sty=
le=3D"color: rgb(0, 0, 255);"><b><span class=3D"keyword">delete</span></b><=
/span> (argument)[] pointer</span> </code>like its counterpart <span style=
=3D"background-color: rgb(207, 226, 243);"><code class=3D"code"><span style=
=3D"color: rgb(0, 0, 255);"><b><span class=3D"keyword">new</span></b></span=
> (argument)[size]</code></span>?<br></div><br>El lunes, 20 de octubre de 2=
014 13:40:55 UTC-5, Farid Mehrabi escribi=C3=B3:<blockquote class=3D"gmail_=
quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;pa=
dding-left: 1ex;"><div dir=3D"rtl"><div dir=3D"ltr">IMHO developing your ow=
n allocator/container system is &nbsp;better and easier than trying to chan=
ge the behavior of new/delete; It is already complicated enough and if not =
for the sake of existing libs and codes relying on new/delete, I wouldn't u=
se them except for the case of placement new. The new/delete predate templa=
tes and therefor lack proper facilities to store customized run-time type i=
nfo.</div><div dir=3D"ltr">IMHO variadic templates and constructor forwardi=
ng, facilitate deriving tools that encourage deprecation of naked use of ne=
w/delete.</div><div dir=3D"ltr">Someday when you get the opportunity to ref=
actor/optimize your personal lib, a good proposal becomes possible. It take=
s more time but less risk.</div><div dir=3D"ltr"><br></div><div>regard,</di=
v><div>FM.</div></div><div><div dir=3D"ltr"><br><div class=3D"gmail_quote">=
2014-10-18 9:32 GMT+03:30  <span dir=3D"ltr">&lt;<a href=3D"javascript:" ta=
rget=3D"_blank" gdf-obfuscated-mailto=3D"_c2w4h-YbjIJ" onmousedown=3D"this.=
href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';ret=
urn true;">con...@ncomputers.org</a>&gt;</span>:<br><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex">David, thank you very much for your answer!<span><br><br><blockquot=
e style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);=
padding-left:1ex" class=3D"gmail_quote">it shouldn=E2=80=99t be a big deal =
when a platform doesn=E2=80=99t support it.</blockquote></span><div><br>I a=
gree with it.<span><br><br><blockquote style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left:1px solid rgb(204,204,204);padding-left:1ex" class=3D"gmail_quote=
">&nbsp;There have been several, but I=E2=80=99m not digging for the others=
 right now.</blockquote></span><div><br>I understand it. So far my experien=
ce says, it is easier to propose something new, than that the proposals bec=
ome accepted. We're excepting that it could even require more than ten year=
s, <br>that the <b>std::allocator</b> become standardized to allow in-place=
 resizing.<br><br>One of our objectives is to share this idea for the impro=
vement of the <b>delete[]</b> operator, so programmers around the world can=
 know it and the right ones, will achieve to standardize such proposals or =
similars.<br><br>The codes that we're writting could free some megabytes of=
 useless data and we're writting in them (commented):<br><br><div style=3D"=
background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-styl=
e:solid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"co=
lor:#800">//Awaiting shrinkable arrays:</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#008">delete</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">[</span><span style=3D"color:#000">oldS=
ize </span><span style=3D"color:#660">-</span><span style=3D"color:#000"> n=
ewSize</span><span style=3D"color:#660">]</span><span style=3D"color:#000">=
 pointer</span><span style=3D"color:#660">;</span><span style=3D"color:#000=
"><br></span></div></code></div><br>So, when shrinkable arrays are possible=
, someone will uncomment the lines and those megabytes of waste can be free=
d.<br><br>Unfortunately we don't have neither the necessary experience nor =
the time to write a paper, which has high possibilities to be accepted and =
standardized, but how do you think, that we can contribute to support every=
 reasonable proposal of what you call:<br><br><blockquote style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" c=
lass=3D"gmail_quote">C++ adaptation of realloc<br></blockquote><div><br>And=
 to make programmers consider the possibility of having a logical <b>new[</=
b>size<b>]</b> and <b>delete[</b>size<b>]</b> operators?<br><br><a href=3D"=
http://ncomputers.org" target=3D"_blank" onmousedown=3D"this.href=3D'http:/=
/www.google.com/url?q\75http%3A%2F%2Fncomputers.org\46sa\75D\46sntz\0751\46=
usg\75AFQjCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return true;" onclick=3D"this.hre=
f=3D'http://www.google.com/url?q\75http%3A%2F%2Fncomputers.org\46sa\75D\46s=
ntz\0751\46usg\75AFQjCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return true;">ncompute=
rs.org</a><br></div></div></div><br>El s=C3=A1bado, 18 de octubre de 2014 0=
0:43:16 UTC-5, David Krauss escribi=C3=B3:<div><div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><div style=3D"word-wrap:break-word"><br><div><div>On 2014=
=E2=80=9310=E2=80=9318, at 1:38 PM, <a>con...@ncomputers.org</a> wrote:</di=
v><br><blockquote type=3D"cite"><div style=3D"font-family:Helvetica;font-si=
ze:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spa=
cing:normal;line-height:normal;text-align:start;text-indent:0px;text-transf=
orm:none;white-space:normal;word-spacing:0px"><div dir=3D"ltr">Thank you ve=
ry much for your time and your answer!<br><br>I didn't understand exactly w=
hat you wrote:<br><br><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-co=
lor:rgb(204,204,204);padding-left:1ex">I=E2=80=99d think the functionality =
could be sliced off any existing malloc.<br></blockquote></div></div></bloc=
kquote><div><br></div><div>Nevin said that resizing malloc allocations woul=
d require a rewrite of malloc. I think that it would not be a total rewrite=
, but only an adaptation of code that should already exist for realloc. And=
 anyway, it shouldn=E2=80=99t be a big deal when a platform doesn=E2=80=99t=
 support it.</div><br><blockquote type=3D"cite"><div style=3D"font-family:H=
elvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:n=
ormal;letter-spacing:normal;line-height:normal;text-align:start;text-indent=
:0px;text-transform:none;white-space:normal;word-spacing:0px"><div dir=3D"l=
tr"><div>I didn't understand this:</div><div><br><blockquote class=3D"gmail=
_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left=
-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">N3495 loo=
ks completely different from the one proposal I recall with a C++ adaptatio=
n of realloc, which also had issues.</blockquote><div><br>Which porposal is=
 "C++ adaptation of realloc"?<br><br>What did you want to express?<br></div=
></div></div></div></blockquote><div><br></div><div>Anything that provides =
a capability to change the size of an allocation without getting into reall=
oc=E2=80=99s requirement of trivial copyability, I=E2=80=99d consider to be=
 a C++ adaptation of realloc. There have been several, but I=E2=80=99m not =
digging for the others right now.</div></div></div></blockquote></div></div=
></blockquote></div><div><div>

<p></p>

-- <br>
<br>
--- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
_c2w4h-YbjIJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"_c2w4h-YbjIJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></div></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr">=
how am I supposed to end the twisted road of&nbsp; your hair in the dark ni=
ght??<br>unless the candle of your face does turn a lamp up on my way!!!<br=
></div>
</div>
</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_3554_1596231722.1413832520011--

.


Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Tue, 21 Oct 2014 18:47:24 +0330
Raw View
--f46d044304dc4b7e000505f05524
Content-Type: text/plain; charset=UTF-8

2014-10-20 22:45 GMT+03:30 <contact@ncomputers.org>:

> I am trying to have an overloaded *delete[]* operator that accepts
> specific arguments. Because the only way to call a *delete[]* operator
> with specific arguments is explicitly, it loses the support for objects
> with destructor
> <http://ncomputers.org/content/code.php?src=examples/shrink%20arrays%205.cpp>.
> I've almost achieved personal shrinkable arrays. This is the last
> complication I have. Do you have any idea of how can we enable a sugar
> syntactic call to an overloaded *delete[]* operator with specific
> arguments: *delete* (argument)[] pointer like its counterpart *new*
> (argument)[size]?
>
>
if you still insist on overloading new - which is too tricky a choice - ,
just define a template function that explicitly destructs the object
pointed to by its args right before calling a deleter routine on it. for
more details just take a look into the implementation of std::vector and
std::allocator. One downside to this approach is that in case constructors
of the allocated objects should throw, clean up must be handled manually.
It is for this reason that IMHO one had better develop a
container/allocator lib rather than trying to play with global new/delete.

regards,
FM.

--

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

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

<div dir=3D"rtl"><br><div class=3D"gmail_extra"><div dir=3D"ltr"><br><div c=
lass=3D"gmail_quote">2014-10-20 22:45 GMT+03:30  <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:contact@ncomputers.org" target=3D"_blank">contact@ncomputers.=
org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 =
..8ex;border-left:1px #ccc solid;border-right:1px #ccc solid;padding-left:1e=
x;padding-right:1ex"><div>I am trying to have an overloaded <span style=3D"=
font-family:courier new,monospace"><b>delete[]</b></span> operator that acc=
epts specific arguments. Because the only way to call a <span style=3D"font=
-family:courier new,monospace"><b>delete[]</b></span> operator with specifi=
c arguments is explicitly, it <a href=3D"http://ncomputers.org/content/code=
..php?src=3Dexamples/shrink%20arrays%205.cpp" target=3D"_blank">loses the su=
pport for objects with destructor</a>. I&#39;ve almost achieved personal sh=
rinkable arrays. This is the last complication I have. Do you have any idea=
 of how can we enable a sugar syntactic call to an overloaded <span style=
=3D"font-family:courier new,monospace"><b>delete[]</b></span> operator with=
 specific arguments: <code><span style=3D"background-color:rgb(207,226,243)=
"><span style=3D"color:rgb(0,0,255)"><b><span>delete</span></b></span> (arg=
ument)[] pointer</span> </code>like its counterpart <span style=3D"backgrou=
nd-color:rgb(207,226,243)"><code><span style=3D"color:rgb(0,0,255)"><b><spa=
n>new</span></b></span> (argument)[size]</code></span>?<br></div><br></bloc=
kquote><div><br></div><div>if you still insist on overloading new - which i=
s too tricky a choice - , just define a template function that explicitly d=
estructs the object pointed to by its args right before calling a deleter r=
outine on it. for more details just take a look into the implementation of =
std::vector and std::allocator. One downside to this approach is that in ca=
se constructors of the allocated objects should throw, clean up must be han=
dled manually.=C2=A0 It is for this reason that IMHO one had better develop=
 a container/allocator lib rather than trying to play with global new/delet=
e.</div><div><br></div><div dir=3D"rtl">regards,</div><div dir=3D"rtl">FM.<=
/div><div dir=3D"rtl">=C2=A0</div></div></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 />

--f46d044304dc4b7e000505f05524--

.


Author: contact@ncomputers.org
Date: Tue, 21 Oct 2014 10:20:44 -0700 (PDT)
Raw View
------=_Part_4496_423872848.1413912044354
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Farid:

Thank you very much for your answers! You are helping me a lot!

take a look into the implementation of std::vector and std::allocator


Ok, I will do it.

Best Regards,

PF, ncomputers.org=20

El martes, 21 de octubre de 2014 10:17:50 UTC-5, Farid Mehrabi escribi=C3=
=B3:
>
>
>
> 2014-10-20 22:45 GMT+03:30 <con...@ncomputers.org <javascript:>>:
>
>> I am trying to have an overloaded *delete[]* operator that accepts=20
>> specific arguments. Because the only way to call a *delete[]* operator=
=20
>> with specific arguments is explicitly, it loses the support for objects=
=20
>> with destructor=20
>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%2=
05.cpp>.=20
>> I've almost achieved personal shrinkable arrays. This is the last=20
>> complication I have. Do you have any idea of how can we enable a sugar=
=20
>> syntactic call to an overloaded *delete[]* operator with specific=20
>> arguments: *delete* (argument)[] pointer like its counterpart *new*=20
>> (argument)[size]?
>>
>>
> if you still insist on overloading new - which is too tricky a choice - ,=
=20
> just define a template function that explicitly destructs the object=20
> pointed to by its args right before calling a deleter routine on it. for=
=20
> more details just take a look into the implementation of std::vector and=
=20
> std::allocator. One downside to this approach is that in case constructor=
s=20
> of the allocated objects should throw, clean up must be handled manually.=
 =20
> It is for this reason that IMHO one had better develop a=20
> container/allocator lib rather than trying to play with global new/delete=
..
>
> regards,
> FM.
> =20
> =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_4496_423872848.1413912044354
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Farid:<br><br>Thank you very much for your answers! You ar=
e helping me a lot!<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; =
border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gma=
il_quote">take a look into the implementation of std::vector and std::alloc=
ator</blockquote><div><br>Ok, I will do it.<br><br>Best Regards,<br><br>PF,=
 ncomputers.org&nbsp;</div><br>El martes, 21 de octubre de 2014 10:17:50 UT=
C-5, Farid Mehrabi escribi=C3=B3:<blockquote class=3D"gmail_quote" style=3D=
"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex=
;"><div dir=3D"rtl"><br><div><div dir=3D"ltr"><br><div class=3D"gmail_quote=
">2014-10-20 22:45 GMT+03:30  <span dir=3D"ltr">&lt;<a href=3D"javascript:"=
 target=3D"_blank" gdf-obfuscated-mailto=3D"ztNwxbhK4SoJ" onmousedown=3D"th=
is.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';=
return true;">con...@ncomputers.org</a>&gt;</span>:<br><blockquote class=3D=
"gmail_quote" style=3D"margin:0 .8ex;border-left:1px #ccc solid;border-righ=
t:1px #ccc solid;padding-left:1ex;padding-right:1ex"><div>I am trying to ha=
ve an overloaded <span style=3D"font-family:courier new,monospace"><b>delet=
e[]</b></span> operator that accepts specific arguments. Because the only w=
ay to call a <span style=3D"font-family:courier new,monospace"><b>delete[]<=
/b></span> operator with specific arguments is explicitly, it <a href=3D"ht=
tp://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%205.cpp=
" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q=
\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fshri=
nk%2520arrays%25205.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFlgsxD2j_m15GdLr=
kqXng3_dbkGw';return true;" onclick=3D"this.href=3D'http://www.google.com/u=
rl?q\75http%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2F=
shrink%2520arrays%25205.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFlgsxD2j_m15=
GdLrkqXng3_dbkGw';return true;">loses the support for objects with destruct=
or</a>. I've almost achieved personal shrinkable arrays. This is the last c=
omplication I have. Do you have any idea of how can we enable a sugar synta=
ctic call to an overloaded <span style=3D"font-family:courier new,monospace=
"><b>delete[]</b></span> operator with specific arguments: <code><span styl=
e=3D"background-color:rgb(207,226,243)"><span style=3D"color:rgb(0,0,255)">=
<b><span>delete</span></b></span> (argument)[] pointer</span> </code>like i=
ts counterpart <span style=3D"background-color:rgb(207,226,243)"><code><spa=
n style=3D"color:rgb(0,0,255)"><b><span>new</span></b></span> (argument)[si=
ze]</code></span>?<br></div><br></blockquote><div><br></div><div>if you sti=
ll insist on overloading new - which is too tricky a choice - , just define=
 a template function that explicitly destructs the object pointed to by its=
 args right before calling a deleter routine on it. for more details just t=
ake a look into the implementation of std::vector and std::allocator. One d=
ownside to this approach is that in case constructors of the allocated obje=
cts should throw, clean up must be handled manually.&nbsp; It is for this r=
eason that IMHO one had better develop a container/allocator lib rather tha=
n trying to play with global new/delete.</div><div><br></div><div dir=3D"rt=
l">regards,</div><div dir=3D"rtl">FM.</div><div dir=3D"rtl">&nbsp;</div></d=
iv></div>
</div></div>
</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_4496_423872848.1413912044354--

.


Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Tue, 21 Oct 2014 21:31:05 +0330
Raw View
--f46d0435c06aa6c0380505f29e57
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

u r welcome. I am sorry; I should find a way of dropping that affirmative
tone from my tongue(hand????), and make more use of  'plz' and 'one might'.

2014-10-21 20:50 GMT+03:30 <contact@ncomputers.org>:

> Farid:
>
> Thank you very much for your answers! You are helping me a lot!
>
> take a look into the implementation of std::vector and std::allocator
>
>
> Ok, I will do it.
>
> Best Regards,
>
> PF, ncomputers.org
>
> El martes, 21 de octubre de 2014 10:17:50 UTC-5, Farid Mehrabi escribi=C3=
=B3:
>>
>>
>>
>> 2014-10-20 22:45 GMT+03:30 <con...@ncomputers.org>:
>>
>> I am trying to have an overloaded *delete[]* operator that accepts
>>> specific arguments. Because the only way to call a *delete[]* operator
>>> with specific arguments is explicitly, it loses the support for objects
>>> with destructor
>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays%=
205.cpp>.
>>> I've almost achieved personal shrinkable arrays. This is the last
>>> complication I have. Do you have any idea of how can we enable a sugar
>>> syntactic call to an overloaded *delete[]* operator with specific
>>> arguments: *delete* (argument)[] pointer like its counterpart *new*
>>> (argument)[size]?
>>>
>>>
>> if you still insist on overloading new - which is too tricky a choice - =
,
>> just define a template function that explicitly destructs the object
>> pointed to by its args right before calling a deleter routine on it. for
>> more details just take a look into the implementation of std::vector and
>> std::allocator. One downside to this approach is that in case constructo=
rs
>> of the allocated objects should throw, clean up must be handled manually=
..
>> It is for this reason that IMHO one had better develop a
>> container/allocator lib rather than trying to play with global new/delet=
e.
>>
>> regards,
>> FM.
>>
>>
>  --

---
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
how am I supposed to end the twisted road of  your hair in the dark night??
unless the candle of your face does turn a lamp up on my way!!!

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

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

<div dir=3D"rtl"><div dir=3D"ltr">u r welcome. I am sorry; I should find a =
way of dropping that affirmative tone from my tongue(hand????), and make mo=
re use of =C2=A0&#39;plz&#39; and &#39;one might&#39;.</div></div><div clas=
s=3D"gmail_extra"><div dir=3D"ltr"><br><div class=3D"gmail_quote">2014-10-2=
1 20:50 GMT+03:30  <span dir=3D"ltr">&lt;<a href=3D"mailto:contact@ncompute=
rs.org" target=3D"_blank">contact@ncomputers.org</a>&gt;</span>:<br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 .8ex;border-left:1px #ccc soli=
d;border-right:1px #ccc solid;padding-left:1ex;padding-right:1ex">Farid:<br=
><br>Thank you very much for your answers! You are helping me a lot!<span c=
lass=3D""><br><br><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left=
:1px solid rgb(204,204,204);padding-left:1ex" class=3D"gmail_quote">take a =
look into the implementation of std::vector and std::allocator</blockquote>=
</span><div><br>Ok, I will do it.<br><br>Best Regards,<br><br>PF, <a href=
=3D"http://ncomputers.org" target=3D"_blank">ncomputers.org</a>=C2=A0</div>=
<br>El martes, 21 de octubre de 2014 10:17:50 UTC-5, Farid Mehrabi escribi=
=C3=B3:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"rtl"><br><div><d=
iv dir=3D"ltr"><br><div class=3D"gmail_quote">2014-10-20 22:45 GMT+03:30  <=
span dir=3D"ltr">&lt;<a>con...@ncomputers.org</a>&gt;</span>:<div><div clas=
s=3D"h5"><br><blockquote class=3D"gmail_quote" style=3D"margin:0 .8ex;borde=
r-left:1px #ccc solid;border-right:1px #ccc solid;padding-left:1ex;padding-=
right:1ex"><div>I am trying to have an overloaded <span style=3D"font-famil=
y:courier new,monospace"><b>delete[]</b></span> operator that accepts speci=
fic arguments. Because the only way to call a <span style=3D"font-family:co=
urier new,monospace"><b>delete[]</b></span> operator with specific argument=
s is explicitly, it <a href=3D"http://ncomputers.org/content/code.php?src=
=3Dexamples/shrink%20arrays%205.cpp" target=3D"_blank">loses the support fo=
r objects with destructor</a>. I&#39;ve almost achieved personal shrinkable=
 arrays. This is the last complication I have. Do you have any idea of how =
can we enable a sugar syntactic call to an overloaded <span style=3D"font-f=
amily:courier new,monospace"><b>delete[]</b></span> operator with specific =
arguments: <code><span style=3D"background-color:rgb(207,226,243)"><span st=
yle=3D"color:rgb(0,0,255)"><b><span>delete</span></b></span> (argument)[] p=
ointer</span> </code>like its counterpart <span style=3D"background-color:r=
gb(207,226,243)"><code><span style=3D"color:rgb(0,0,255)"><b><span>new</spa=
n></b></span> (argument)[size]</code></span>?<br></div><br></blockquote><di=
v><br></div><div>if you still insist on overloading new - which is too tric=
ky a choice - , just define a template function that explicitly destructs t=
he object pointed to by its args right before calling a deleter routine on =
it. for more details just take a look into the implementation of std::vecto=
r and std::allocator. One downside to this approach is that in case constru=
ctors of the allocated objects should throw, clean up must be handled manua=
lly.=C2=A0 It is for this reason that IMHO one had better develop a contain=
er/allocator lib rather than trying to play with global new/delete.</div><d=
iv><br></div><div dir=3D"rtl">regards,</div><div dir=3D"rtl">FM.</div><div =
dir=3D"rtl">=C2=A0</div></div></div></div></div>
</div></div>
</blockquote></blockquote></div>

<p></p>

-- <br><div class=3D"HOEnZb"><div class=3D"h5">
<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></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr">=
how am I supposed to end the twisted road of=C2=A0 your hair in the dark ni=
ght??<br>unless the candle of your face does turn a lamp up on my way!!!<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 />

--f46d0435c06aa6c0380505f29e57--

.


Author: contact@ncomputers.org
Date: Thu, 23 Oct 2014 11:24:24 -0700 (PDT)
Raw View
------=_Part_413_470948151.1414088664934
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


>
> I should find a way of dropping that affirmative tone from my=20
> tongue(hand????), and make more use of  'plz' and 'one might'.
>

I think that you are kind enough.
=20
Am Dienstag, 21. Oktober 2014 13:02:33 UTC-5 schrieb Farid Mehrabi:
>
> u r welcome. I am sorry; I should find a way of dropping that affirmative=
=20
> tone from my tongue(hand????), and make more use of  'plz' and 'one might=
'.
>
> 2014-10-21 20:50 GMT+03:30 <con...@ncomputers.org <javascript:>>:
>
>> Farid:
>>
>> Thank you very much for your answers! You are helping me a lot!
>>
>> take a look into the implementation of std::vector and std::allocator
>>
>>
>> Ok, I will do it.
>>
>> Best Regards,
>>
>> PF, ncomputers.org=20
>>
>> El martes, 21 de octubre de 2014 10:17:50 UTC-5, Farid Mehrabi escribi=
=C3=B3:
>>>
>>>
>>>
>>> 2014-10-20 22:45 GMT+03:30 <con...@ncomputers.org>:
>>>
>>> I am trying to have an overloaded *delete[]* operator that accepts=20
>>>> specific arguments. Because the only way to call a *delete[]* operator=
=20
>>>> with specific arguments is explicitly, it loses the support for=20
>>>> objects with destructor=20
>>>> <http://ncomputers.org/content/code.php?src=3Dexamples/shrink%20arrays=
%205.cpp>.=20
>>>> I've almost achieved personal shrinkable arrays. This is the last=20
>>>> complication I have. Do you have any idea of how can we enable a sugar=
=20
>>>> syntactic call to an overloaded *delete[]* operator with specific=20
>>>> arguments: *delete* (argument)[] pointer like its counterpart *new*=20
>>>> (argument)[size]?
>>>>
>>>>
>>> if you still insist on overloading new - which is too tricky a choice -=
=20
>>> , just define a template function that explicitly destructs the object=
=20
>>> pointed to by its args right before calling a deleter routine on it. fo=
r=20
>>> more details just take a look into the implementation of std::vector an=
d=20
>>> std::allocator. One downside to this approach is that in case construct=
ors=20
>>> of the allocated objects should throw, clean up must be handled manuall=
y. =20
>>> It is for this reason that IMHO one had better develop a=20
>>> container/allocator lib rather than trying to play with global new/dele=
te.
>>>
>>> regards,
>>> FM.
>>> =20
>>> =20
>>  --=20
>
> ---=20
> You received this message because you are subscribed to the Google Groups=
=20
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
=20
> email to std-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> Visit this group at=20
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
> --=20
> how am I supposed to end the twisted road of  your hair in the dark night=
??
> unless the candle of your face does turn a lamp up on my way!!!
> =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_413_470948151.1414088664934
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-lef=
t: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">=
 I should find a way of dropping that affirmative tone from my tongue(hand?=
???), and make more use of &nbsp;'plz' and 'one might'.<br></blockquote><di=
v><br>I think that you are kind enough.<br>&nbsp;</div>Am Dienstag, 21. Okt=
ober 2014 13:02:33 UTC-5 schrieb Farid Mehrabi:<blockquote class=3D"gmail_q=
uote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;pad=
ding-left: 1ex;"><div dir=3D"rtl"><div dir=3D"ltr">u r welcome. I am sorry;=
 I should find a way of dropping that affirmative tone from my tongue(hand?=
???), and make more use of &nbsp;'plz' and 'one might'.</div></div><div><di=
v dir=3D"ltr"><br><div class=3D"gmail_quote">2014-10-21 20:50 GMT+03:30  <s=
pan dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscate=
d-mailto=3D"dQpqPotZJuoJ" onmousedown=3D"this.href=3D'javascript:';return t=
rue;" onclick=3D"this.href=3D'javascript:';return true;">con...@ncomputers.=
org</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 =
..8ex;border-left:1px #ccc solid;border-right:1px #ccc solid;padding-left:1e=
x;padding-right:1ex">Farid:<br><br>Thank you very much for your answers! Yo=
u are helping me a lot!<span><br><br><blockquote style=3D"margin:0px 0px 0p=
x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class=3D"g=
mail_quote">take a look into the implementation of std::vector and std::all=
ocator</blockquote></span><div><br>Ok, I will do it.<br><br>Best Regards,<b=
r><br>PF, <a href=3D"http://ncomputers.org" target=3D"_blank" onmousedown=
=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncomputers.org\=
46sa\75D\46sntz\0751\46usg\75AFQjCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ';return tru=
e;" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fncom=
puters.org\46sa\75D\46sntz\0751\46usg\75AFQjCNGu9y3wXgJPa-68kCF9PEFnWBBJpQ'=
;return true;">ncomputers.org</a>&nbsp;</div><br>El martes, 21 de octubre d=
e 2014 10:17:50 UTC-5, Farid Mehrabi escribi=C3=B3:<blockquote class=3D"gma=
il_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"rtl"><br><div><div dir=3D"ltr"><br><div class=
=3D"gmail_quote">2014-10-20 22:45 GMT+03:30  <span dir=3D"ltr">&lt;<a>con..=
..@ncomputers.org</a>&gt;</span>:<div><div><br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0 .8ex;border-left:1px #ccc solid;border-right:1px #cc=
c solid;padding-left:1ex;padding-right:1ex"><div>I am trying to have an ove=
rloaded <span style=3D"font-family:courier new,monospace"><b>delete[]</b></=
span> operator that accepts specific arguments. Because the only way to cal=
l a <span style=3D"font-family:courier new,monospace"><b>delete[]</b></span=
> operator with specific arguments is explicitly, it <a href=3D"http://ncom=
puters.org/content/code.php?src=3Dexamples/shrink%20arrays%205.cpp" target=
=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fshrink%2520a=
rrays%25205.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFlgsxD2j_m15GdLrkqXng3_d=
bkGw';return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\75h=
ttp%3A%2F%2Fncomputers.org%2Fcontent%2Fcode.php%3Fsrc%3Dexamples%2Fshrink%2=
520arrays%25205.cpp\46sa\75D\46sntz\0751\46usg\75AFQjCNFlgsxD2j_m15GdLrkqXn=
g3_dbkGw';return true;">loses the support for objects with destructor</a>. =
I've almost achieved personal shrinkable arrays. This is the last complicat=
ion I have. Do you have any idea of how can we enable a sugar syntactic cal=
l to an overloaded <span style=3D"font-family:courier new,monospace"><b>del=
ete[]</b></span> operator with specific arguments: <code><span style=3D"bac=
kground-color:rgb(207,226,243)"><span style=3D"color:rgb(0,0,255)"><b><span=
>delete</span></b></span> (argument)[] pointer</span> </code>like its count=
erpart <span style=3D"background-color:rgb(207,226,243)"><code><span style=
=3D"color:rgb(0,0,255)"><b><span>new</span></b></span> (argument)[size]</co=
de></span>?<br></div><br></blockquote><div><br></div><div>if you still insi=
st on overloading new - which is too tricky a choice - , just define a temp=
late function that explicitly destructs the object pointed to by its args r=
ight before calling a deleter routine on it. for more details just take a l=
ook into the implementation of std::vector and std::allocator. One downside=
 to this approach is that in case constructors of the allocated objects sho=
uld throw, clean up must be handled manually.&nbsp; It is for this reason t=
hat IMHO one had better develop a container/allocator lib rather than tryin=
g to play with global new/delete.</div><div><br></div><div dir=3D"rtl">rega=
rds,</div><div dir=3D"rtl">FM.</div><div dir=3D"rtl">&nbsp;</div></div></di=
v></div></div>
</div></div>
</blockquote></blockquote></div>

<p></p>

-- <br><div><div>
<br>
--- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
dQpqPotZJuoJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"dQpqPotZJuoJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></div></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr">=
how am I supposed to end the twisted road of&nbsp; your hair in the dark ni=
ght??<br>unless the candle of your face does turn a lamp up on my way!!!<br=
></div>
</div>
</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_413_470948151.1414088664934--

.