Range that iterates the indices of the set bits in value. Index 0 corresponds to the least significant bit. For signed integers, the highest index corresponds to the sign bit.
import std.algorithm.comparison : equal; import std.range : iota; assert(bitsSet(1).equal([0])); assert(bitsSet(5).equal([0, 2])); assert(bitsSet(-1).equal(iota(32))); assert(bitsSet(int.min).equal([31]));
See Implementation
Range that iterates the indices of the set bits in value. Index 0 corresponds to the least significant bit. For signed integers, the highest index corresponds to the sign bit.