Generic test bit function (core.bitop)

Pierre cathary.pierre at neuf.fr
Tue Mar 6 10:37:30 UTC 2018


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)
  if(__traits(isIntegral,T))
  {
     return p[bitnum/ (T.sizeof*8)] & (1 << (bitnum& ((T.sizeof*8) 
- 1)));
  }

Thank you for your help.


More information about the Digitalmars-d-learn mailing list