On Tuesday, 6 March 2018 at 10:37:30 UTC, Pierre wrote:
Hi all,

I would like to use bt function (core.bitop) on generic array but it seems that's not possible. I would like to know if there is some reasons to have a fixed type (size_t) instead of something like :

 pure @system int bt(T)(in T* p,size_t bitnum)
return p[bitnum/ (T.sizeof*8)] & (1 << (bitnum& ((T.sizeof*8) - 1)));

Thank you for your help.

From this point of view, size_t is not fixed, but capable to point to any place in memory. Therefore, pointer of any type have by definition exactly the defined size of size_t.

If you want to use an array (or an object of custom type) as a bit array, there is for example
which fits more, I think...

Reply via email to