◆ ffs()

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

This function object returns the index of the first bit set (beginning with the least significant bit) in the parameter.

Header <boost/simd/function/ffs.hpp>
See also
firstbitset, firstbitunset
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::ffs(pi) = " << bs::ffs(pi) << '\n';
std::uint32_t xi = 2;
std::cout << "---- scalar" << '\n'
<< "<- xi = " << xi << '\n'
<< "-> bs::ffs(xi) = " << bs::ffs(xi) << '\n';
return 0;
}
Possible output:
---- simd
<- pi = (1, 2, 10, 1023)
-> bs::ffs(pi) = (1, 2, 2, 1)
---- scalar
<- xi = 2
-> bs::ffs(xi) = 2