Le 20/04/2017 à 11:07, Dawid Pilarski a écrit :
> Recently when dealing with some algorithms I had lots of need to find
> msb and lsb in a bitset, but there is no portable way to count them
> (except own implementation with O(n) complexity). I think this could
> be improved with adding msb() and lsb() methods to the std::bitset class.
>
> Compilers currently have their own builtins, that can compute
> following in a constant time, so implementation of msb and lsb methods
> could be efficient and portable. Standard could simply say, that
> complexity of those operations are O(n) or better.
I believe we need to have (constant?) access to the array of blocks (a
span?). Why it is preferable to work on this array? Because we can have
other types that need this kind of information independently of whether
it represents a bit set or big integer.
This doesn't mean that we don't need algorithm msb, lsb, that iterates
over this array.
This should be an extension to
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0553r1.html
My 2 cts,
Vicente