Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?


You 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;}




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: