3 ms·
I suspect the OP expected something like: struct Array{void *ptr; uint64_t len; uint64_t cap;} sizeof(struct Array) //24 At any rate, a simple way to get
by norir 3y ago
I suspect the OP expected something like:
struct Array{void *ptr; uint64_t len; uint64_t cap;}
sizeof(struct Array) //24
At any rate, a simple way to get to 16 bytes is the following:
struct Array{void *ptr; uint32_t len; uint32_t cap;}
How often does one really need a general array with more than 4B elements?
- alcover 3y agoYou are right. My reply was a bit silly. Now thanks to alignment you could use spare bits in the pointer to afford bigger lengths. struct Array{int64_t ptr:60; uint64_t len:34, cap:34;}