◆ firstbitset()

as_integer_t<Value> boost::simd::firstbitset ( Value const &  x)

This function object returns the bit pattern in which the only bit set is the first bit set (beginning with the least significant bit) in the parameter.

See also
ffs, firstbitunset
Header <boost/simd/function/firstbitset.hpp>
Example:
#include <boost/simd/bitwise.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
int main() {
pack_it pi = {1, 2, 10, 1023};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> bs::firstbitset(pi) = " << bs::firstbitset(pi) << '\n';
std::uint32_t xi = 2;
std::cout << "---- scalar" << '\n'
<< "<- xi = " << xi << '\n'
<< "-> bs::firstbitset(xi) = " << bs::firstbitset(xi) << '\n';
return 0;
}
Possible output:
---- simd
<- pi = (1, 2, 10, 1023)
-> bs::firstbitset(pi) = (1, 2, 2, 1)
---- scalar
<- xi = 2
-> bs::firstbitset(xi) = 2