I noticed that std::bitset does not have a function for returning or popping the lowest set bit of a bitset (nor the highest set bit for that matter). What is the fastest way to accomplish this task, specifically for std::bitset objects not guaranteed to be a certain number of bits long? I looked in the g++ compiler extensions and C++20 numerics library and didn't find anything related to my problem.
Two obvious methods to consider would be looping over the length of the bitset and using the operator[]
or gradually shifting the bitset using operator>>
until the first set bit is found.
You can do something like this: