◆ ctz()

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

This function object returns the bit count of trailing zeroes.

Header <boost/simd/function/ctz.hpp>
Notes
  • It finds the first bit set in x, and returns the index of that bit, 0 being the least significant bit index.
  • ctz asserts is the entry is 0
See also
clz, popcnt
Header <boost/simd/function/ctz.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::ctz(pi) = " << bs::ctz(pi) << '\n';
std::uint32_t xi = 2;
std::cout << "---- scalar" << '\n'
<< "<- xi = " << xi << '\n'
<< "-> bs::ctz(xi) = " << bs::ctz(xi) << '\n';
return 0;
}
Possible output:
---- simd
<- pi = (1, 2, 10, 1023)
-> bs::ctz(pi) = (0, 1, 1, 0)
---- scalar
<- xi = 2
-> bs::ctz(xi) = 1