Wednesday, March 11, 2015

Digest for comp.lang.c++@googlegroups.com - 2 updates in 1 topic

JiiPee <no@notvalid.com>: Mar 11 09:40PM

On 11/03/2015 21:15, Paavo Helde wrote:
>> double* c = new double[size ];
> This is not exactly equivalent to std::vector because the capacity and
> efficient dynamic resizing are missing.
 
ok but lets assume that project does not need them here....
 
 
>> so in C we need total : 4 bytes overhead
> 16 bytes, if you want to compare correctly. Each pointer is an overhead.
> And if you add capacities, it will make 28 bytes.
 
yes, forgot them. we dont add capacity....
 
 
> std::vector<X> x;
 
> Voila: this has 12 bytes overhead,
 
>> which is 4 bytes less than the C
 
 
But if you use the same struct with C (which would be fair here), then
you get:
 
int size = 10;
X* x = new X[size];
 
With 8 bytes overhead.
JiiPee <no@notvalid.com>: Mar 11 09:41PM

On 11/03/2015 21:29, Mr Flibble wrote:
> thing: allocating uninitialised buffers of char; use std::vector for
> everything else..
 
> /Flibble
 
but the issue here is using as little RAM memory as possible
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: