E.V.E  0.1-beta

◆ countr_one

eve::countr_one = {}
inlineconstexpr

Callable object computing the number of consecutive 1 bits right.

Required header: #include <eve/function/countr_one.hpp>

Members Functions

Member Effect
operator() the computation of the number of consecutive 1 bits right
operator[] Construct a conditional version of current function object

auto operator()(unsigned_value auto x) const noexcept;
Definition: value.hpp:63

Parameters

x: unsigned value.

Return value

Returns the number of consecutive 1 ("one") bits in the value of x , starting from the less significant bit ("right"), with same type as x..


auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::countr_one

Parameters

cond : conditional expression

Return value

A Callable object so that the expression countr_one[cond](x, ...) is equivalent to if_else(cond,countr_one(x, ...),x)


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/countr_one.hpp>
#include <eve/constant/inf.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_it pi = {14, 1, 3, 0};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> countr_one(pi) = " << eve::countr_one(pi) << '\n';
std::uint32_t xf = 48;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> countr_one(xf) = " << eve::countr_one(xf) << '\n';
return 0;
}
constexpr callable_countr_one_ countr_one
Callable object computing the number of consecutive 1 bits right.
Definition: countr_one.hpp:72
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
Wrapper for SIMD registers.
Definition: wide.hpp:65